Categories > TinyButStrong general >

returning $_GET from subtemplate

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: handoko
Date: 2010-06-20
Time: 01:52

returning $_GET from subtemplate

Dear team,

I have a problem when accessing url from a sub template, the link won't work or it doesn't fill  the $_GET['page'] variable when i click into the subtemplate link.

what is the problem?
By: TomH
Date: 2010-06-20
Time: 04:25

Re: returning $_GET from subtemplate


Please, provide the PHP and HTML code

This time do cut & paste of complete code no more psuedo-code, please.
By: handoko
Date: 2010-06-20
Time: 06:42

Re: returning $_GET from subtemplate

hi TomH,

the code is the same as your sub template example, but there are modification like this,

i have htaccess file,
Options -Indexes

<IfModule mod_rewrite.c>
 
  RewriteEngine On
  RewriteBase /
  RewriteRule ^\.htaccess$ - [F]

  RewriteRule ^art/[^.]([0-9]+)\.html$ index.php?art=$1 [L,NC]
 
</IfModule>

ErrorDocument 500 "<h2>Application error</h2>Application failed to start properly"
ErrorDocument 404 /?page=staticcontent&amp;field=pagenotfound&amp;title=PageNotFound

and this is subtplmenu.html
<html>
<head>
<title>TinyButStrong - Examples - subtemplate menu</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>


<p><strong><a href="art/subarticle0.html">Main Page</a></strong><br>
<!--
<p><strong><a href="[onshow..script_name]?art=0">Main Page</a></strong><br> -->
  <strong><a href="[onshow..script_name]?art=1">Heading 1</a></strong><br>
  <strong><a href="[onshow..script_name]?art=2">Heading 2</a></strong><br>
  <u><strong><a href="[onshow..script_name]?art=3">Heading 3</a></strong></u><br>
&nbsp;</p>

</body>
</html>

index.php file
<?php


// Check if subscript's source is asked.
if (isset($_GET['subsrc'])) {
  show_source('subtpllogin.php');
  exit;
}

// Prepare variabes
if (isset($_GET['art'])) {
    $art = $_GET['art'];
}    else {
    $art = 0;
}

$tmpl_article = 'art/subtplarticle'.$art.'.html';
$tmpl_menu = 'subtplmenu.html';

// Merging main template
include_once('tbs_class.php');
$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('subtpl.html');
$TBS->Show();

?>

subtpl.html
<html>
<head>
<title>TinyButStrong - Examples - subtemplates</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="subtpl.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="w3cinfo"> this TBS template is W3C compliant <a href="http://validator.w3.org/check?uri=referer" target="_top"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" width="59" height="21" border="0"></a> </div>
<h1>Example of subtemplate</h1>
<div align="center">
  <table width="500" border="0" align="center" cellpadding="2" cellspacing="0">
    <tr>
      <td><p>Parameter <span class="text-prm">file</span> enables you to include a static sub-template into the main template.<br>
        Parameter <span class="text-prm">script</span>, with parameter <span class="text-prm">subtpl</span>, enable you to include a dynamic sub-template.
        <br>
        <br>
          <span class="text-section2">In this example, header and footer are static sub-templates. 
          Headings are also static-sub-templates but they depends to a global variable ($tmpl_article). The login area is a dynamic sub-template. It is managed by a sub-script which can be run under the TBS Subtemplate Mode. <br>
</span><br>
        </p></td>
    </tr>
  </table>
  <br>
  <table width="500" border="1" cellspacing="0" cellpadding="2">
    <tr valign="top" bgcolor="#FFCC99">
      <td height="40" colspan="2" bgcolor="#D1F3D2">[onload;file='subtplheader.html';getbody]</td>
    </tr>
    <tr>
      <td colspan="2" valign="top" bgcolor="#FFCC99">[onload;script=subtpllogin.php;subtpl;getbody]</td>
    </tr>
    <tr>
      <td width="100" valign="top" bgcolor="#FFCCCC">[onload;file=[var.tmpl_menu];getbody]</td>
      <td valign="top" bgcolor="#B1B1B1">[onload;file=[var.tmpl_article];getbody]<br>
&nbsp;</td>
    </tr>
    <tr bgcolor="#D1F3D2">
      <td colspan="2" valign="top" bgcolor="#D1F3D2">[onload;file='subtplfooter.html';getbody]</td>
    </tr>
  </table>
  <br>
  <table width="500" border="0" cellpadding="0" cellspacing="0" class="text-mini">
    <tr>
      <td>- See <a href="tbs_us_examples_subtpl_header.htm">Header sub-template</a><br>
        - See <a href="tbs_us_examples_subtpl_footer.htm">Footer sub-template</a><br>
        - See <a href="tbs_us_examples_subtpl_menu.htm">Menu sub-template</a><br>
        - See <a href="tbs_us_examples_subtpl_article0.htm">Main Page sub-template</a><br>
        - See <a href="tbs_us_examples_subtpl_article1.htm">Heading 1 sub-template </a><br>
        - See <a href="tbs_us_examples_subtpl_article2.htm">Heading 2 sub-template</a> <br>
        - See <a href="tbs_us_examples_subtpl_article3.htm">Heading 3 sub-template</a><br>
        - See <a href="[onshow..script_name]?subsrc">Login sub-script source </a> <br>
        - See <a href="tbs_us_examples_subtpl_login.htm">Login sub-template </a> </td>
    </tr>
  </table>
</div>
</body>
</html>

while the other file is the same as sub template example.

the problem is when i use rewriting mode, and i change the href from
"[onshow..script_name]?art=0"
into
"art/subarticle0.html"

the css file didn't bring up to figure out the overall template,
Please help,


By: handoko
Date: 2010-06-20
Time: 06:45

Re: returning $_GET from subtemplate

and after i click the "main page"
the login page script doesn't work at all, or didn't capture the post input.

your kind help, thanks

i think the main problem is when i want use rewriting mode in the script.

By: Skrol29
Date: 2010-06-20
Time: 23:54

Re: returning $_GET from subtemplate

Hi,

There is a TBS bug with parameter "getbody" used without value. TBS do not load the <body> part according to the manual, but the full contents. In your case, it load the full subtemplate including the CSS link. In "subtpl.html", can you replace "getbody" with "getbody=body"?
This may fix you CSS problem.

>and after i click the "main page"
>the login page script doesn't work at all, or didn't capture the post input.

I cannot reproduce your problem. Can you give more detail on what you do, what you expect to have , and what you have instead?
I have to say your Rewrite Rule did not work for me, my Apache did show me the index page of my local server instead of the expected page.
I used instead:
RewriteRule ^art_subarticle([0-9]+)\.html$ /tbs/debug/handoko/index.php?art=$1 [L,NC]
and I changed the links "art/subarticle0.html" into "art_subarticle0.html".
By: handoko
Date: 2010-06-21
Time: 00:28

Re: returning $_GET from subtemplate

hi thanks skrol,

yes this is a bug, the link to css file doesn't load when i click main page, except the entire body of sub template,..

how do i fix this problem?
what i expect is a Search Engine Friendly URL work with sub templete mode.

you can try it on http://subtpl.safeourlife.info

first click the main page link (SEF URL), and see the css doesn't implented,

second, click the login user field, it doesn't work,

except you click heading1, heading2 and heading3, which don't implement rewrite rule to make SEF url.


By: Skrol29
Date: 2010-06-21
Time: 01:28

Re: returning $_GET from subtemplate

For the bug, you must replace "getbody" with "getbody=body" in the "subtpl.html" file. I hope this will fix the CSS problem.


"http://subtpl.safeourlife.info" is not working for me. Error: too long to reply
By: Skrol29
Date: 2010-06-22
Time: 15:39

Re: returning $_GET from subtemplate

Hi Handoky,

I've reproduced your bug with the style which is lost when clicking on the link "application/art/subarticle0.html".

The browser call:
   "application/art/subarticle0.html"
Then Apache rewrites the URL and returns the content of:
   "application/index.php?art=0"
But only Apache knows that the content comes from another URL, the browser assumes it comes from "application/art/subarticle0.html".

The content is an HTML file with a CSS link that refers to "subtpl.css". This link is local, and this is the browser that will ask for this file, so its ask for "application/art/subtpl.css" but this link is invalid.

So the problem is that you're rewriting the URL with a different folder, which makes the CSS link invalid.
By: handoko
Date: 2010-08-14
Time: 04:39

Re: returning $_GET from subtemplate

dear skrol,

the problem has been resolved, by putting the long path into css link, like this :
<link href="http://localhost/subtpl.css" rel="stylesheet" type="text/css">

i am happy now.

thanks