Include in a link

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
salto
Forum Commoner
Posts: 31
Joined: Thu Jul 04, 2002 7:50 am

Include in a link

Post by salto »

Is it possible to process an include via a link, like (not working example)

Code: Select all

<a href="<?php include 'test.incl'; ?>">test</a>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

No, all that code would do is include the contents of test.incl between as the href attribute. If test.incl contained:

Code: Select all

<html><body>somestuff</body></html>
The result of the posted code would be:

Code: Select all

<a href="<html><body>somestuff</body></html>">test</a>
What exactly are you trying to achieve? Have you read this:
http://www.devnetwork.net/forums/viewtopic.php?t=1030

Mac
salto
Forum Commoner
Posts: 31
Joined: Thu Jul 04, 2002 7:50 am

Post by salto »

Thanks Mac.
What I try to achieve is something like an 'expand', without the usual javascript incompatibilities. As (non-working) example:

Code: Select all

<a href="begin.htm">Begin</a><br>
Want to see more? <a href="<?php include 'more1.inc'; ?>">Click here</a><br>
<a href="second.htm">Second</a><br>
Want to see more? <a href="<?php include 'more2.inc'; ?>">Click here</a>
and so on

I need more1.inc and more2.inc to be includes because I use the contents of these files on some other places on the site as well and want an easy update.
And yes, I know I can do this with javascript 'show layers' but then I have other issues so this seemed to me an easier way - if possible that is.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Please read this sticky post which talks about the difference between PHP and Javascript: http://www.devnetwork.net/forums/viewtopic.php?t=1030

The page would have to be refreshed in order to achieve what you're looking for. You could use a switch statement to determine which section of the menu should be expanded by passing a variable through the query string when you click on the link to expand the menu. You would then have your include statements for the chunks of code in the switch statement - not in the URL (which as I pointed out above, will not work). So you can use PHP to do this but you will have to have the page refresh each time a menu item is expanded or collapsed.

Mac
salto
Forum Commoner
Posts: 31
Joined: Thu Jul 04, 2002 7:50 am

Post by salto »

Thanks Mac. Clear.
I'll put it in layers and use javascript
And yes, I read the sticky post, of course!
Post Reply