Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
PHP in templates
Goto page Previous  1, 2, 3  Next
 
Reply to topic    Forum Index » Additional Downloads View previous topic
View next topic
PHP in templates
Author Message
T0M



Joined: 23 Sep 2007
Posts: 11

Post Reply with quote
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:
<?php echo pun_htmlspecialchars($pun_user['username']); ?>


Can anyone tell me where im going wrong with this?[/code]
Sun Sep 23, 2007 2:06 pm View user's profile Send private message
Guest








Please login to hide the ads.

T0M



Joined: 23 Sep 2007
Posts: 11

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


Code:

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:
<?php echo pun_htmlspecialchars(\$pun_user['username']); ?>


which causes no output or errors Confused

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:
<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 />
?>




Tue Sep 25, 2007 3:43 pm View user's profile Send private message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post Reply with quote
Are you sure that the $pun_user variable is available on this page?
Fri Sep 28, 2007 3:03 pm View user's profile Send private message
T0M



Joined: 23 Sep 2007
Posts: 11

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


Thanks for taking the time to reply Very Happy

Yes the variable is available on the page , i use it on every page including my cutenews homepage in the sidebar example below
Code:
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 Crying or Very sad
Sun Sep 30, 2007 3:45 pm View user's profile Send private message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post Reply with quote
If it's not working in the templates you still can use the variable in inc/show.news.php, can't you?
Tue Oct 02, 2007 6:03 pm View user's profile Send private message
T0M



Joined: 23 Sep 2007
Posts: 11

Post Reply with quote
Will give that a go. Smile
Wed Oct 03, 2007 10:00 am View user's profile Send private message
T0M



Joined: 23 Sep 2007
Posts: 11

Post Reply with quote
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:
$output = str_replace('{password}', $member['password'], $output);


After Add
Code:
$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.
Thu Oct 18, 2007 5:23 pm View user's profile Send private message
SickQuilver



Joined: 12 Mar 2008
Posts: 15
Location: Amsterdam, The Netherlands

Post Reply with quote
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?
Mon Mar 31, 2008 8:38 am View user's profile Send private message
scottdallas



Joined: 04 May 2006
Posts: 1843
Location: US

Post Reply with quote
I use <?=cn_title(); ?>

_________________
www.scottdizzle.com uses cnr Smile
last update: 07-22-08: 8:30 pm
Tue Apr 01, 2008 6:03 pm View user's profile Send private message Visit poster's website AIM Address
snatch518



Joined: 07 Jun 2008
Posts: 8

Post I'm having trouble too... Reply with quote
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?
Sat Jun 07, 2008 4:24 pm View user's profile Send private message
Goberg



Joined: 18 Jan 2007
Posts: 43

Post Re: I'm having trouble too... Reply with quote
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:
<?PHP
 \$static['number'] = "5";
 \$static['template'] = "flerenyheter";
 \$PHP_SELF = "news.php";
 include $cutepath.'/show_news.php';
?>

Mon Jun 09, 2008 3:34 am View user's profile Send private message
Mystic2010



Joined: 10 Jan 2007
Posts: 50

Post Reply with quote
May not be the solution, but I noticed you didn't escape the $cutepath. $cutepath -> \$cutepath
Mon Jun 09, 2008 12:40 pm View user's profile Send private message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post Reply with quote
There's no need to do this using this plugin. Check the readme to learn how to show articles below the full story.
Tue Jun 10, 2008 6:45 pm View user's profile Send private message
fmanfredi



Joined: 22 Aug 2007
Posts: 9

Post Reply with quote
worked perfect to my... thank you very much!! Very Happy
Wed Jun 11, 2008 6:16 pm View user's profile Send private message
snatch518



Joined: 07 Jun 2008
Posts: 8

Post php Reply with quote
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.
Wed Jun 11, 2008 11:52 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    Forum Index » Additional Downloads All times are GMT + 1 Hour
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum



Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Music Lyrics.