1
xsell
assign page to Template. not working
  • 2009/12/14 21:22

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


Hello

I have Made very Simple Module to add comment to html pages without useing any content Modules to wrap it up .

all working but I could not assign the html page to the template .

this is the Module index content


include("../../mainfile.php");

$xoopsOption['template_main'] = 'com.html';
include(
XOOPS_ROOT_PATH."/header.php");


if(isset(
$_GET['get']))
{
  if (
file_exists($_GET['get'].'.html')) {
   include 
$_GET['get'].'.html';
   }
} else {
  include 
'anything.html';
}
$xoopsTpl->assign"page"$_GET['get'].'.html' );
include 
XOOPS_ROOT_PATH.'/include/comment_view.php';
include(
"../../footer.php");
?>


to call Page .
Quote:

as u can see i assigned pages with html end to the template with smarty verible called page

$xoopsTpl->assign"page"$_GET['get'].'.html' );


Now in my template i have this

{include file=$page}

<
div style="text-align: center; padding: 3px;
margin:3px;"
>
<{
$commentsnav}>
<{
$lang_notice}>
div>

<
div style="margin:3px; padding: 3px;">

<{if 
$comment_mode == "flat"}>
<{include 
file="db:system_comments_flat.html"}>
<{elseif 
$comment_mode == "thread"}>
<{include 
file="db:system_comments_thread.html"}>
<{elseif 
$comment_mode == "nest"}>
<{include 
file="db:system_comments_nest.html"}>
<{/if}>

div>


and when i call the page as mentioned above . it opens the page but ignors the "{include file=$page}" this makes the comment Navgatore Shows above the Contenet instaed in the Bottom ..

any idea .. whts wrong

2
ghia
Re: assign page to Template. not working
  • 2009/12/14 22:59

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


In the template use <{include ...}>
In PHP do not the include of the HTML file or it will be displayed twice. Instead use the tests to assign the correct file to the template.

3
xsell
Re: assign page to Template. not working
  • 2009/12/14 23:10

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


Thx Ghia

If you mean this
<{include file=$page}>

and in the php

$xoopsTpl->assign( "page", $_GET['get'].'test.html' );

i tried it and still Same thing .. it dose not Show the assigned page but Shows the Page it self .. Other words .in the template file this code dose not do any thing
<{include file=$page}>

4
ghia
Re: assign page to Template. not working
  • 2009/12/14 23:45

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Maybe add starting with XOOPS_ROOT_PATH the full path of the file in the assign of the template.
Set Smarty debug on, to check that the variables are set with the expected values.
Because
$xoopsTpl->assign"page"$_GET['get'].'test.html' );
is assigning test.html.test.html, following your URL example.

5
xsell
Re: assign page to Template. not working
  • 2009/12/15 2:09

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


I HAVE TRIED THE FULL URL IDEA AND I HAVE DEBUG ON .. AND NO ERORR .

6
ghia
Re: assign page to Template. not working
  • 2009/12/15 10:22

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Did you check the value of variable page?

7
xsell
Re: assign page to Template. not working
  • 2009/12/15 20:42

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


yes Ghia .. i still do not see why this not working.
<{include file=$page}>


i will try rename the html files to use tpl format instaed html . and see if that makes different .. if not i'm thinking to use MySQL to store the html page and call it with id and see how that goes.

8
trabis
Re: assign page to Template. not working
  • 2009/12/15 22:22

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


My test:
Made a index.php:
include dirname(dirname(dirname(__FILE__))) . '/mainfile.php';
$xoopsOption['template_main'] = 'template_main.html';
include 
XOOPS_ROOT_PATH '/header.php';
$xoopsTpl->assign"page"XOOPS_ROOT_PATH '/modules/xteste/templates/' $_GET['get'].'.html' );
include 
XOOPS_ROOT_PATH '/footer.php';


Added 3 files in templates folder:
template_main.html
Template Main <br />
<{include 
file=$page}>


template_yes.html
Yes


template_no.html
No


Added in xoops_version.php
// Templates
$modversion['templates'][1]['file'] = 'template_main.html';
$modversion['templates'][1]['description'] = '';


Access modules/xteste/index?get=template_yes
Result:
Quote:
Template Main
Yes


Access modules/xteste/index?get=template_no
Result:
Quote:
Template Main
No

9
xsell
Re: assign page to Template. not working
  • 2009/12/16 0:59

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


thx trabis .. that worked , as matter of fact Some guy told me to do kINDA like your tutorial but i did not try it , was not clear to me as your way .. Anyway i have Moved On to make it with MySQL tabel store the html page.

Thx again :)

Login

Who's Online

358 user(s) are online (255 user(s) are browsing Support Forums)


Members: 0


Guests: 358


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits