Template variables/switches/loops in php

Tutorials for <a href="http://www.phpbbstyles.com/viewtopic.php?t=356">eXtreme Styles mod</a> for phpBB 2.0.

Moderator: Moderators

Postby xkevinx on Mon Nov 15, 2004 1:18 am

Ok I am trying to figure out what to do here. Im adding a poll block to my portal i designed and i cant figure out how to change some of the loops so that it will parse.
Heres the code. Taken from Smarters exportal.
Code: Select all
<div align="center">
              <div align="center" class="gensmall"><b><?php echo $this->vars[S_POLL_QUESTION];?></b></div>
              <br />
              <!-- BEGIN poll_option_row -->
              <input type="radio" name="vote_id" value="<?php echo $postrow_item[poll_option_row.OPTION_ID];?>" />
              <span class="gensmall"><?php echo $this->vars[poll_option_row.OPTION_TEXT];?>&nbsp;[<?php echo $this->vars[poll_option_row.VOTE_RESULT];?>]</span><br />
              <!-- END poll_option_row -->
              <br />
              <!-- BEGIN switch_user_logged_out -->
              <div align="center">{L_LOGIN_TO_VOTE}</div>
              <!-- END switch_user_logged_out -->
              <!-- BEGIN switch_user_logged_in -->
              <div align="center" class="gensmall">
                <input type="submit" class="mainoption" name="submit2" value="{L_VOTE_BUTTON}" {DISABLED} />
              </div>
              <input type="hidden" name="topic_id" value="{S_TOPIC_ID}" />
              <input type="hidden" name="mode" value="vote" />
              <!-- END switch_user_logged_in -->
              <br />
            </div>

The poll question shows up but non of the other stuff does. What do I need to change to make this work.
xkevinx
Registered User
Registered User
 
Posts: 1
Joined: Mon Nov 15, 2004 1:07 am
Location: California

Postby PostBot on Mon Nov 15, 2004 8:29 am

$this->vars[S_POLL_QUESTION]; should be $this->vars['S_POLL_QUESTION']; (you forgot quotes. S_POLL_QUESTION is a string, not constant)
$postrow_item[poll_option_row.OPTION_ID]; should be $poll_option_row_item['OPTION_ID']; (use name of last loop iteration and add _item to it)
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Postby SamuelDr on Tue Jan 11, 2005 5:28 am

Hi CyberAlien !
Yout add-on is poweriffic (is this a word ???)
but, I can't find how to handle this hot potatoe :

Code: Select all
<?php

function menu_phpBB() { ?>
<li><a href="#">phpBB</a></li>
<hr>
<a href="<?php echo $this->vars['U_FAQ'] ?>" class="mainmenu"><img src="templates/subSilver/images/icon_mini_faq.gif" width="12" height="13" border="0" hspace="3" /><?php echo $this->vars['L_FAQ'] ?></a>


<!-- BEGIN switch_user_logged_out -->
<a href="{U_REGISTER}" class="mainmenu">      <img src="templates/subSilver/images/icon_mini_register.gif" width="12" height="13" border="0" hspace="3" />{L_REGISTER}</a></span>
<!-- END switch_user_logged_out -->
<?php }

$titre = "Forum";
$menu = "phpbb";
include_once("/path/to/my/header.php"); ?>


PS: It's my menu system, i'm inserting my board into my web template, but the menu is separated... i can't handle it in another way...

When I do not try to add phpBB templates variables into my menu, it's working...
But when I try this, it's not working : "<?php echo $this->vars['U_FAQ'] ?>" it shows nothing...

And on the other hand, I want the switch working... I know that my vars are not set well, but I tested these only with FAQ.

I don't know if it's php related question or XS related... so, I need clear indications... I'll be able to use temporary solutions on waiting.

¯¯
Hope it'll be working SamuelDr

P-S: Sorry for my english, if I make mistakes, it's because I mainly speak french !
SamuelDr
Registered User
Registered User
 
Posts: 5
Joined: Tue Jan 11, 2005 5:10 am

Postby PostBot on Tue Jan 11, 2005 10:56 am

You are using $this inside function, so it won't work. Use $template->vars instead of $this->vars and at the beginning of your function add this code: global $template;
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Postby SamuelDr on Tue Jan 11, 2005 1:37 pm

Thank you very much CyberAlien !
It was so simple... but I didn't see it :P

thank you again

SamuelDr
SamuelDr
Registered User
Registered User
 
Posts: 5
Joined: Tue Jan 11, 2005 5:10 am

Postby SamuelDr on Wed Jan 12, 2005 4:01 am

Hi, again me !
unless I'm blind (that would be surprising !) I didn't see any informations on how to use the switches like <!-- BEGIN switch_user_logged_out --> into this topic...

So, telle me I'm blind and telle where I didn't look, or please help me with this issue.

SamuelDr
Yep, again me !
SamuelDr
Registered User
Registered User
 
Posts: 5
Joined: Tue Jan 11, 2005 5:10 am

expanding menus

Postby ludedude on Wed Jan 12, 2005 7:49 am

HI, I'm looking for code to use within the portal tpl to transform the forum link into an expanding link that "trees" out with mouse over to show the differetn forums/sub forums (CH2.1)

As well code to make a "post to" jump box on the portal and index. Instead of just having a jump to box for viewing I'd like to add one that brings the user directly to the posting page of the selected section.


Thanks for any help...
ludedude
Registered User
Registered User
 
Posts: 7
Joined: Wed Dec 08, 2004 12:12 am

Postby PostBot on Wed Jan 12, 2005 10:33 am

SamuelDr: For simple switches like switch_user_logged_in use code like this:
Code: Select all
<?php

$switch_user_logged_in_count = ( isset($this->_tpldata['switch_user_logged_in.']) ) ?  sizeof($this->_tpldata['switch_user_logged_in.']) : 0;
if($switch_user_logged_in_count > 0)
{

    // user is logged in

}

?>



ludedude: please post it to appropriate forum. your question has absolutely nothing to do with this thread.
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Postby SamuelDr on Sat Jan 15, 2005 3:52 am

hmmm... sorry for being slow to answer, but it's not working...
this code :

Code: Select all
<?php

function menu_phpBB() {
global $template; ?>
<li><a href="<?php echo $template->vars['U_INDEX'] ?>">Index</a></li>
[...]
<li><a href="<?php echo $template->vars['U_GROUP_CP'] ?>"><?php echo $template->vars['L_USERGROUPS'] ?></a></li>


<!-- BeeeeeeEGIN switch_user_logged_out -->
<?php
$switch_user_logged_in_count = ( isset($this->_tpldata['switch_user_logged_in.']) ) ?  sizeof($this->_tpldata['switch_user_logged_in.']) : 0;
if($switch_user_logged_in_count > 0)
{
    // user is logged in
    //echo '<li><a href="'.$template->vars['U_REGISTER'].'"><inmg src="templates/subSilver/images/icon_mini_register.gif" width="12" height="13" border="0" hspace="3" />'.$template->vars['L_REGISTER'].'</a></li>';
    echo '<br><br>TEST<br><br>';
}
?>
<!-- EeeeeeeeeND switch_user_logged_out -->

[...]

<?php }

[...] ?>


Note : The function "menu_phpBB()" is a function for design purpose, I make the menu in the start of this page, and I call the main design of my website... it's really no matter... i'm a hundred or more percents sure that it's not interfering...

Is simply not working...
the [...] are deleted part of code, mostly HTML.

Thanks again
SamuelDr
Registered User
Registered User
 
Posts: 5
Joined: Tue Jan 11, 2005 5:10 am

Postby PostBot on Sat Jan 15, 2005 10:16 am

Again, you are using code inside function. So you should change $this to $template
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Postby SamuelDr on Sat Jan 15, 2005 9:06 pm

Sorry -_- I didn't seen the '$this' inside the function...
I'm surely blind :D
SamuelDr
Registered User
Registered User
 
Posts: 5
Joined: Tue Jan 11, 2005 5:10 am

Postby Hater on Wed Feb 09, 2005 9:39 am

Why is there no detailed explaination on how to use the newly backported tags like INCLUDE. I've had this MOD installed since the beginning, and had NO IDEA how powerful it really was until I was bored one night and started sneaking around the code.

I said it another post, and I'll say it here to get my point across...

I am so utterly greatful for this MOD and the convenience it has offerred me. (You really couldn't understand how much time you have saved me) :)
Hater
Registered User
Registered User
 
Posts: 4
Joined: Wed Feb 09, 2005 9:30 am

Postby chaosonline on Tue Feb 15, 2005 9:54 am

Im trying to use the append_sid function in the overall_header.tpl file, and it wont return any URL.

Does the header file support this?
chaosonline
Registered User
Registered User
 
Posts: 1
Joined: Mon Feb 07, 2005 6:05 am
Location: Saint Cloud, MN

Postby PostBot on Tue Feb 15, 2005 10:28 am

Look at your page source. If you see php code then you installed extreme styles mod incorrectly.
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Postby Gogi on Wed Sep 14, 2005 4:24 pm

Hi,
how I can change this code to show banner on index.php and forum with id = 5, but on all other pages to show banner2


Code: Select all
<?php
global $forum_id; 
if($forum_id == 5) 

?> 

banner

<?php 

?>
Gogi
Registered User
Registered User
 
Posts: 8
Joined: Tue Jun 22, 2004 2:32 am
Location: made in Russia

PreviousNext

Return to eXtreme Styles mod tutorials

Who is online

Users browsing this forum: No registered users and 1 guest