Categories > TinyButStrong general >

php into sub-template htm

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Yotis
Date: 2008-05-27
Time: 00:07

php into sub-template htm

Hello all!

I'm trying to put a menu into a sub-template.If TBS IS NOT USED the code should look like this:
  <div class="MenuButtons_main">
    <ul>
      <li><a href="index.php" <?php if ($PHP_SELF=='index.php') {echo ' class="selected" '}?>>Home</a></li>
     </ul>
   </div>
but since
<?php if...?>
is not allowed by TBS, the is have somehow to load this line from a loadphpmenu.php.
I know how the loadphpmenu.php general structure should look like, but I don't knwo how to call the php line.I should be something like this:
$home = '<?php if ($PHP_SELF=='index.php') {echo ' class="selected" '}?>'
and then into htm:
<li><a href="index.php" [var_home]>Home</a></li>
The
class="selected"
will be defined in a .css file

Thank you for any help that I may receive!

Br,
Yotis
By: ege
Date: 2008-05-27
Time: 00:30

Re: php into sub-template htm

hi Yotis,

You may try this:
<li><a href='index.php' [var.page;if [val]=='index.php';then 'class="selected"';else '']>Home</a></li>


On php side, you should have a global $page variable, which you would most likely initialize it $page=$PHP_SELF. I didn't test the code but should be somtihgn similar to that. I wish there was a simpler way, something like [onshow;class='selected';when [var.page]=='index.php'], maybe forum members or skrol29 may help out on that.
By: Yotis
Date: 2008-05-27
Time: 00:49

Re: php into sub-template htm

Thanks,

I'll try this in a few minutes.
By: Yotis
Date: 2008-05-27
Time: 01:10

Re: php into sub-template htm

Is not working as it supposed :(
By: ege
Date: 2008-05-27
Time: 01:42

Re: php into sub-template htm

It should.

Maybe you should replace val with the actual value like this:
<li><a href='index.php' [var.page;if [var.page]=='index.php';then 'class="selected"';else '']>Home</a></li>
If it's not working maybe your php is wrong. I wrote similar code so many times, so I'm pretty sure about the basic structure. I might be wrong about double and single quotes but the genereal structure should work.