PHP in templates

Download plugins, language packs and stuff.

Postby T0M » Sun Sep 23, 2007 2:06 pm

Ramon wrote:Neh thats a global of SDK. SDK is a IPB integration tool.



I do not have a name field if people want to comment, they only have to type in their comment and the $member_name get's there name from the database when logged in. So al my forum members can also post on the website with their forum account and in that way members don't have to also sign up for a cutenews.ru account.



^^^ Crappy English, sorry about that, bit tired ^^^


I have been trying to do the same using PunBB and have had no luck yet, whenever i try to include a punbb variable into the comments template i get an error about whitespace.

I have tried to do this many ways, the recommended code from punbb is the following


Code: Select all
<?php echo pun_htmlspecialchars($pun_user['username']); ?>


Can anyone tell me where im going wrong with this?[/code]
T0M
 
Posts: 11
Joined: Sun Sep 23, 2007 2:00 pm

Please help

Postby T0M » Tue Sep 25, 2007 3:43 pm

Following on from my post above here is the exact error i get when trying to include
Code: Select all
<?php echo pun_htmlspecialchars($pun_user['username']); ?>


Code: Select all
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in


After re-reading this thread i have tried to escape the variable as follows
Code: Select all
<?php echo pun_htmlspecialchars(\$pun_user['username']); ?>


which causes no output or errors :?

I have also tried alien13's mod of inc/show.news.php which hasn't helped me and have tried including the code without full php tags using <? ?> and without using php tags too.

Iam trying to include the php into the comments form template but being able to put it in any template would be a good start.

Below is an example of what iam trying to do (please excuse the tables and else echo statement)

Code: Select all
<h2>Leave a comment</h2>
<?php if ($pun_user['is_guest'])
message("You must login to use leave a comment"); else echo [not-logged]
<input type="hidden" name="name2" tabindex="1" value="<?php echo pun_htmlspecialchars(\$pun_user['username']); ?>" />
[/not-logged]
</p>
</p>

<table width="500" border="0">
  <tr>
    <td><noindex>{smilies}</noindex> <br></td>
  </tr>
  <tr>
    <td>  <noindex>{bbcodes}</noindex></td>
  </tr>
</table>
<p><textarea cols="100" rows="8" name="comments" tabindex="3"></textarea>
  <br />
  <input class="input" type="submit" tabindex="4" name="submit" value="Leave a comment" />
  <br />
?>



T0M
 
Posts: 11
Joined: Sun Sep 23, 2007 2:00 pm

Postby FI-DD » Fri Sep 28, 2007 3:03 pm

Are you sure that the $pun_user variable is available on this page?
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby T0M » Sun Sep 30, 2007 3:45 pm

FI-DD wrote:Are you sure that the $pun_user variable is available on this page?


Thanks for taking the time to reply :D

Yes the variable is available on the page , i use it on every page including my cutenews homepage in the sidebar example below
Code: Select all
Welcome <?php echo pun_htmlspecialchars(\$pun_user['username']); ?> !
so i don't see why it won't work. I have also made a test page and tried to output the variable more than once to see if this is the problem but its not that either :cry:
T0M
 
Posts: 11
Joined: Sun Sep 23, 2007 2:00 pm

Postby FI-DD » Tue Oct 02, 2007 6:03 pm

If it's not working in the templates you still can use the variable in inc/show.news.php, can't you?
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby T0M » Wed Oct 03, 2007 10:00 am

Will give that a go. :)
T0M
 
Posts: 11
Joined: Sun Sep 23, 2007 2:00 pm

Postby T0M » Thu Oct 18, 2007 5:23 pm

Thanks for a point in the right direction FI-DD , has been something i have been trying to do for a long time.

Incase anyone else wanted to do this too i have posted instructions below.

Open inc/show.commentform.php

Find line 21
Code: Select all
$output = str_replace('{password}', $member['password'], $output);


After Add
Code: Select all
$output = str_replace('{puname}',  $pun_user['username'], $output);


Now you can include the variable in the comments form by using {puname} dont forget to include common.php in you page also, the above code is for punbb intergration but can be edited for other forum scripts.
T0M
 
Posts: 11
Joined: Sun Sep 23, 2007 2:00 pm

Postby SickQuilver » Mon Mar 31, 2008 8:38 am

I'm trying somthing like this:

<?PHP $cntitle = {title}; ?>

i want the title in a email form i include this form from a extern file: include form.php

but i want the title in the value option from the input form:
<input size="111" name="thesubject" tabindex="4" value="Reactie op: <?PHP echo"$cntitle" ?>" disabled>

but i'm not getting it to work.

is there a other way to include the title? is there a standard var?
SickQuilver
 
Posts: 20
Joined: Wed Mar 12, 2008 10:23 am
Location: Amsterdam, The Netherlands

Postby scottdallas » Tue Apr 01, 2008 6:03 pm

I use <?=cn_title(); ?>
Everyday I'm tumblin http://scodal.tumblr.com
User avatar
scottdallas
 
Posts: 2209
Joined: Thu May 04, 2006 6:46 pm
Location: US

I'm having trouble too...

Postby snatch518 » Sat Jun 07, 2008 4:24 pm

I'm running 2.5 and I want to include PHP in my templates so I can display the 10 latest articles from the articles page... does anyone know what to do yet?
snatch518
 
Posts: 8
Joined: Sat Jun 07, 2008 6:29 am

Re: I'm having trouble too...

Postby Goberg » Mon Jun 09, 2008 3:34 am

snatch518 wrote:I'm running 2.5 and I want to include PHP in my templates so I can display the 10 latest articles from the articles page... does anyone know what to do yet?


same problem here, im trying to show the last 5 news from all categories at the end of the full story. here is the code im using to include the news:

Code: Select all
<?PHP
\$static['number'] = "5";
\$static['template'] = "flerenyheter";
\$PHP_SELF = "news.php";
include $cutepath.'/show_news.php';
?>
Goberg
 
Posts: 79
Joined: Thu Jan 18, 2007 2:31 pm

Postby Mystic2010 » Mon Jun 09, 2008 12:40 pm

May not be the solution, but I noticed you didn't escape the $cutepath. $cutepath -> \$cutepath
Mystic2010
 
Posts: 51
Joined: Wed Jan 10, 2007 6:36 pm

Postby FI-DD » Tue Jun 10, 2008 6:45 pm

There's no need to do this using this plugin. Check the readme to learn how to show articles below the full story.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby fmanfredi » Wed Jun 11, 2008 6:16 pm

worked perfect to my... thank you very much!! :D
fmanfredi
 
Posts: 9
Joined: Wed Aug 22, 2007 9:36 pm

php

Postby snatch518 » Wed Jun 11, 2008 11:52 pm

Is this only for 1.2? I'm using 2.5 and want to include PHP and the installation readme doesn't match the code I have.
snatch518
 
Posts: 8
Joined: Sat Jun 07, 2008 6:29 am

PreviousNext

Return to Additional Downloads



Who is online

Users browsing this forum: No registered users and 0 guests

cron