dynamic inclusion subpages

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 4141 Views - Last Post: 10 August 2011 - 05:20 PM Rate Topic: -----

#1 fragmentx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 07-August 11

dynamic inclusion subpages

Posted 07 August 2011 - 07:00 PM

Hi everyone. I tried doing this before and it's work, and i have forgotten how to do it again. Can anyone please help me with this please?

I'm trying to do the dynamic inclusion subpages, but when i do just the dynamic inclusion it still wouldn't work.

Here is my main page " http://fragmentx.bloghead.com "


http://fragmentx.bloghead.com/sub.pdf

http://fragmentx.blo...c_inclusion.pdf

This post has been edited by fragmentx: 07 August 2011 - 07:05 PM


Is This A Good Question/Topic? 0
  • +

Replies To: dynamic inclusion subpages

#2 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 934
  • View blog
  • Posts: 2,329
  • Joined: 15-February 11

Re: dynamic inclusion subpages

Posted 07 August 2011 - 08:10 PM

Could you explain in a bit more detail what you're trying to accomplish. Do you mean autoloading?
Was This Post Helpful? 0
  • +
  • -

#3 fragmentx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 07-August 11

Re: dynamic inclusion subpages

Posted 07 August 2011 - 09:00 PM

View Postcodeprada, on 07 August 2011 - 08:10 PM, said:

Could you explain in a bit more detail what you're trying to accomplish. Do you mean autoloading?

not necessary. I'm trying to build a site and including links to it, but using those techniques.
Like:
INDEX
1
a
b
2
a
b
c
c
3
4
....so forth.

This post has been edited by fragmentx: 07 August 2011 - 09:03 PM

Was This Post Helpful? 0
  • +
  • -

#4 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 934
  • View blog
  • Posts: 2,329
  • Joined: 15-February 11

Re: dynamic inclusion subpages

Posted 07 August 2011 - 09:56 PM

You could make a number of HTML files and then depending on the number passed to your script you will read and display the contents of the HTML file.
HINT: file_get_contents()

This post has been edited by codeprada: 07 August 2011 - 10:05 PM

Was This Post Helpful? 1
  • +
  • -

#5 fragmentx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 07-August 11

Re: dynamic inclusion subpages

Posted 07 August 2011 - 10:16 PM

here are some pages that i'd like to have.

http://fragmentx.blo...d.com/blend.php
...you.php
...info.php
Was This Post Helpful? 0
  • +
  • -

#6 fragmentx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 07-August 11

Re: dynamic inclusion subpages

Posted 08 August 2011 - 12:10 AM

here is my index.php
<? include("header.php"); ?>

<?php
$page = basename($x);
if(!$x)
include("default.php");
else 
include("$x.php")
?>

<? include("footer.php"); ?>



My default.php
<?PHP
 $number = "5";
 $category = "3";
 include("cutenews/show_news.php");
?>

Was This Post Helpful? 0
  • +
  • -

#7 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 994
  • View blog
  • Posts: 3,547
  • Joined: 05-June 09

Re: dynamic inclusion subpages

Posted 08 August 2011 - 02:08 AM

I don't get it?

Why are you mixing your PHP opening tags so much, you're using <? then <?php then <?PHP, wtf?

Anyway, what's actually happening, does your code not work? Is only default.php ever being loaded? What is $x?

So many questions, so little information! Help us to help you.
Was This Post Helpful? 0
  • +
  • -

#8 fragmentx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 07-August 11

Re: dynamic inclusion subpages

Posted 08 August 2011 - 07:35 AM

View PostRudiVisser, on 08 August 2011 - 02:08 AM, said:

I don't get it?

Why are you mixing your PHP opening tags so much, you're using <? then <?php then <?PHP, wtf?

Anyway, what's actually happening, does your code not work? Is only default.php ever being loaded? What is $x?

So many questions, so little information! Help us to help you.

Sorry about mixing the php. I didn't know i was doing it =[

I'm trying to do inclusion, so that it'll be easier to modify. Instead of changing the whole thing, I can just change the layout part (header.php/footer.php).

$x is just something to refer the links to when you click on it.

I hope i make sense.
Was This Post Helpful? 0
  • +
  • -

#9 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 994
  • View blog
  • Posts: 3,547
  • Joined: 05-June 09

Re: dynamic inclusion subpages

Posted 08 August 2011 - 07:58 AM

Yes but $x is not defined in your script, so where did it come from?

What happens when you run your code?
Was This Post Helpful? 0
  • +
  • -

#10 fragmentx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 07-August 11

Re: dynamic inclusion subpages

Posted 08 August 2011 - 08:03 AM

View PostRudiVisser, on 08 August 2011 - 07:58 AM, said:

Yes but $x is not defined in your script, so where did it come from?

What happens when you run your code?

what do you mean? I follow the instructions from this tutorial: http://fragmentx.blo...c_inclusion.pdf
Was This Post Helpful? 0
  • +
  • -

#11 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 994
  • View blog
  • Posts: 3,547
  • Joined: 05-June 09

Re: dynamic inclusion subpages

Posted 08 August 2011 - 08:14 AM

I've just read it, that won't work - Ignore it, it's a load of rubbish.

You need to be using $_GET['x'], you could do $x = $_GET['x']; but this is a bad way to do things, there are much much better ways to do this and I'm sure there's a few tutorials around here somewhere.

If you can't find one I'll write one up for you tonight..
Was This Post Helpful? 0
  • +
  • -

#12 fragmentx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 07-August 11

Re: dynamic inclusion subpages

Posted 08 August 2011 - 08:27 AM

View PostRudiVisser, on 08 August 2011 - 08:14 AM, said:

I've just read it, that won't work - Ignore it, it's a load of rubbish.

You need to be using $_GET['x'], you could do $x = $_GET['x']; but this is a bad way to do things, there are much much better ways to do this and I'm sure there's a few tutorials around here somewhere.

If you can't find one I'll write one up for you tonight..

you can do that? Thanks.
Was This Post Helpful? 0
  • +
  • -

#13 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 934
  • View blog
  • Posts: 2,329
  • Joined: 15-February 11

Re: dynamic inclusion subpages

Posted 08 August 2011 - 08:42 AM

Dynamic inclusions aren't hard once you know basic PHP.

Consider this...
<?php
$pages = array('about' => 'aboutus.html', 'contact' => 'contactus.html');
if(array_key_exists($_GET['page'], $pages))
{
	echo file_get_contents($pages[$_GET['page']]);
}
?>


You've got the pages array which ensures that we'll only include the pages we want to include. If the value of $_GET['page'] doesn't exist in the array then we'll assume someone is trying to pass us a 6 for a 9. If the key does exists then we'll echo HTML contents of the associated page.
Was This Post Helpful? 0
  • +
  • -

#14 fragmentx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 07-August 11

Re: dynamic inclusion subpages

Posted 08 August 2011 - 01:22 PM

View Postcodeprada, on 08 August 2011 - 08:42 AM, said:

Dynamic inclusions aren't hard once you know basic PHP.

Consider this...
<?php
$pages = array('about' => 'aboutus.html', 'contact' => 'contactus.html');
if(array_key_exists($_GET['page'], $pages))
{
	echo file_get_contents($pages[$_GET['page']]);
}
?>


You've got the pages array which ensures that we'll only include the pages we want to include. If the value of $_GET['page'] doesn't exist in the array then we'll assume someone is trying to pass us a 6 for a 9. If the key does exists then we'll echo HTML contents of the associated page.

where would i put that? and do i have to include all the pages i want in there?

This post has been edited by fragmentx: 08 August 2011 - 01:22 PM

Was This Post Helpful? 0
  • +
  • -

#15 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 994
  • View blog
  • Posts: 3,547
  • Joined: 05-June 09

Re: dynamic inclusion subpages

Posted 08 August 2011 - 03:48 PM

Bulk of the tutorial is written as promised :)

http://rudiv.se/Blog...d-more-with-php
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2