How do I add new variable in a .TPL file

This is a discussion on "How do I add new variable in a .TPL file" within the PHP Forum section. This forum, and the thread "How do I add new variable in a .TPL file are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack (1) Thread Tools
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old Oct 9th, 2006, 04:44
New Member
Join Date: Oct 2006
Location: California
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
[Solved] How do I add new variable in a .TPL file

I need a solution to what's bound to be a really simplistic problem. I'm running a php/mysql script on my site and one of the functions it performs to display a news/text post and dynamically link it to a corresponding image file. If you're thinking "webcomic" you're right on the money. The news posts are formatted according to a .tpl file.

The script itself is Comikaze and I've tried contacting the creator, but I've not heard anything back for quite some time and after several attempts.

The thing I need help with is that I need to insert a link into that .tpl (news_print.tpl) file that will dynamically link from the news post to the corresponding image page. I've discovered that simply inserting PHP into the news_print.tpl file does not work. What I thought I'd do would be to define a new variable that I'd be able to use inside the news_print.tpl file.

Variables that already exist are {NES_AVATAR}, {NEWS_POST}, {NEWS_DATE}, {NEWS_POSTER}, and a few others.

The variable I need is already used by the script elsewhere as $comic_id; the comic rotation/navigation uses it to, well "navigate." However how to turn it into something that news_print.tpl can use... that's what I'm not sure about. I did some serious digging and I found this specific file that looks like it has to do with the news_print.tpl, and is called newsDO.class.php. Inside the code on line #48 begins the following code:
PHP: Select all

function formatNewsPost($poster,$email,$avatar,$title,$post,$time,$nl2br) {
    
$post $this->nl2brNewsPost($post,$nl2br);
    if (!empty(
$avatar))
        
$avatar "<img src=\"$avatar\" alt=\"$poster\" border=\"0\" />";
    
$replace['{NEWS_POSTER}'] = $poster;
    
$replace['{NEWS_EMAIL}'] = $email;
    
$replace['{NEWS_AVATAR}'] = $avatar;
    
$replace['{NEWS_TITLE}'] = $title;
    
$replace['{NEWS_POST}'] = $post;
    
$replace['{NEWS_DATE}'] = $time;
        
    return 
$this->_common->getTemplate('news_print.tpl'$replace);

I thought that if I added $comic_id into the function call on the first line and the $replace['{COMIC_ID}'] = $comic_id; down with the rest that this would allow me to use {COMIC_ID} as a variable with the news_print.tpl file. Unfortunately, all it does when I attempt to use it is spits out this error:
Code: Select all
Warning: Missing argument 8 for formatnewspost() in /var/www/html/smcomikaze/includes/classes/newsDO.class.php on line 48
My website is essentially done, this is the last bit of code I need to wedge into it and *poof* off it goes. Once I can get this to work it's keg time!

Thanks to anyone who's taken the time to read this over!

Last edited by toasty; Oct 9th, 2006 at 18:27. Reason: Found solution
Reply With Quote

  #2 (permalink)  
Old Oct 9th, 2006, 18:27
New Member
Join Date: Oct 2006
Location: California
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How do I add new variable in a .TPL file

Figured it out!

I was forgetting to update all the function calls with the new variable. Woo Hoo!!
Reply With Quote
Reply

Tags
variable, tpl, php

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.webforumz.com/php-forum/9531-how-do-i-add-new-variable.htm
Posted By For Type Date
Web Design Forums - Web design and development help and discussion This thread Refback Oct 9th, 2006 16:42

Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax to include a file as a variable??? WebNinja PHP Forum 7 Feb 5th, 2008 11:00
[SOLVED] Sending variable from one php file to another eon201 PHP Forum 2 Oct 31st, 2007 15:48
Creating a log file (text file) and an XML file using XSL kdelacruz Other Programming Languages 1 Nov 4th, 2006 21:12
Is it possible to use an external text file for a variable AdRock JavaScript Forum 2 Sep 15th, 2006 17:25
How make Word file same as html file in ASP humair Classic ASP 5 Sep 24th, 2003 14:35


All times are GMT. The time now is 11:49.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43