Author Topic: include in index.php site template ?!  (Read 10975 times)

0 Members and 1 Guest are viewing this topic.

Offline PartyPix

  • Newbie
  • *
  • Posts: 42
    • View Profile
include in index.php site template ?!
« on: April 28, 2006, 05:30:26 PM »
Hi
how can I include my news in the index.php to show that in the index.html ?

I have make this way but I dont know why it dont go.

index.php

Quote
$site_template->register_vars("news", include("templates/default/news/mynews.inc.php"));

index.html

Quote
{news}

But the news will be display in the top of the page and when I delete {news} it will be show, too. How can I make this better ???? What must I change ?


Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: include in index.php site template ?!
« Reply #1 on: April 28, 2006, 06:07:38 PM »
What is in your "mynews.inc.php" ? does it output anything on the screen when executed?
If it does, then maybe you can try something like this:
Code: [Select]
ob_start();
include("templates/default/news/mynews.inc.php"));
$mynews = ob_get_contents();
ob_end_clean();
$site_template->register_vars("news", $mynews);
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline PartyPix

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: include in index.php site template ?!
« Reply #2 on: April 29, 2006, 01:13:35 AM »
V@no you are PERFECT !! ;) That was the right way, a lot of Thanks !!

Offline tommyboy

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: include in index.php site template ?!
« Reply #3 on: November 12, 2008, 02:37:05 PM »
Quote
ob_start();
include("templates/default/news/mynews.inc.php"));
$mynews = ob_get_contents();
ob_end_clean();
$site_template->register_vars("news", $mynews);

Where does this code go? Is it possible to make an complete step-by-step guide for us?
I still have trubble with including my phpbb header(php) and this may be a solution for it.

Anybody?
edit2: i got this working ""echo "Hello Footer";"" with this method but the rest is not showing.
« Last Edit: November 16, 2008, 12:00:25 AM by tommyboy »

Offline kandr

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: include in index.php site template ?!
« Reply #4 on: March 16, 2009, 12:17:49 AM »
to V@no -

how can paste two {news} ? - In this example, the conclusion is repeated 3 times. How best to make the templates that are not permanently embed the same code, and paste {name_of_template}

Code: [Select]
ob_start();

include(ROOT_PATH.'templates/test.html');
$test = ob_get_contents();


include(ROOT_PATH.'templates/test1.html');
$test1 = ob_get_contents();


ob_end_clean();
$site_template->register_vars("test", $test);
$site_template->register_vars("test1", $test1);

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: include in index.php site template ?!
« Reply #5 on: March 16, 2009, 03:05:20 AM »
no, you'll need repeat it as many times as you need:
Code: [Select]
ob_start();
include("templates/default/news/mynews1.inc.php"));
$mynews = ob_get_contents();
ob_end_clean();
$site_template->register_vars("news1", $mynews);

ob_start();
include("templates/default/news/mynews2.inc.php"));
$mynews = ob_get_contents();
ob_end_clean();
$site_template->register_vars("news2", $mynews);

ob_start();
include("templates/default/news/mynews3.inc.php"));
$mynews = ob_get_contents();
ob_end_clean();
$site_template->register_vars("news3", $mynews);

I didn't understand you last question.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline kandr

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: include in index.php site template ?!
« Reply #6 on: March 16, 2009, 03:28:56 PM »
thanks, everythink is OK! :D