PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
php variables from Joomla Article to Template (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: php variables from Joomla Article to Template


#614
plgard (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
php variables from Joomla Article to Template 3 Years, 9 Months ago Karma: 0  
I'm new to Joomla. I'm using version 1.5.5.

I've created a template with content being loaded by "echoed" php variables. My plan was to declare the variables in a Joomla article, hoping, that my content would show up neatly organized in my template in all the intened places.

I started by using "jumi" and just "including" two files. One with the content by way of declared variables and the other an html/php template with variables echoed.


Code:
{jumi [files/article_content.inc]}
{jumi [files/article_template.php]}
That worked, but maintaining a file with content defeats the purpose of a database. So I added the template code to the joomla template "templates/ja_purity/html/com_content/article/default.php" The template looks fine, it understandibly has no content but displays as intended. Then, I installed "includePHP" intending to enter my "content" directly in the Joomla article using php code to declare my variables.
Code:
{php}$reviewdate = 12 / 31 / 2007;{/php}
{php}$reviewer = Paul;{/php}
{php}$bio = ($_SERVER['DOCUMENT_ROOT'] . "/ssi/bio-plg.php");{/php}
{php}$manufacturer = Rapala;{/php}
{php}$product = Original Floater;{/php}
{php}$idvote = originalfloater;{/php}
{php}$msrp = 6.99;{/php}
{php}$street = 5.99;{/php}
{php}$imgthumbs = /images/misc/LabThumbsUp.jpg;{/php}
{php}$altthumbs = Thumbs Up!;{/php}
{php}$testbed01 = Rods: St. Croix;{/php}
{php}$testbed02 = Reels: Shimano;{/php}
{php}$testbed03 = Line: SpiderWire;{/php}
That did not work. I've included a file: "files/article_content.inc" in the template: "templates/ja_purity/html/com_content/article/default.php" just above the following line "<?php echo $this->article->text; ?>" and that worked. So this "thing" seems possible, but so far I can't declare and pass variables from a Joomla "Article" to a Joomla "template" using code alone as opposed to included files. I've tried this using "includePHP" "Sourcerer" and "DirectPHP" - - Still not working. Any help would be great! Thanks
 
 
Last Edit: 2008/08/07 01:19 By plgard.
  The administrator has disabled public write access.

#626
kksou (Admin)
Admin
Posts: 1599
graph
User Online Now Click here to see the profile of this user
Re:php variables from Joomla Article to Template 3 Years, 9 Months ago Karma: 23  
I'm not sure if I quite get what what you're trying to do.

If I understand correctly, the codes above appear in your content item e.g. <?php>$reviewdate = "12 / 31 / 2007";</php>

And you're trying to access these variables from some functions located within article_template.php.

If you're using DirectPHP, and you're accessing these variables e.g. $reviewdate within some funcitons located in article_template.php, make sure you add

global $reviewdate;

in these functions.

Regards,
/kksou
 
  The administrator has disabled public write access.

#630
plgard (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Re:php variables from Joomla Article to Template 3 Years, 9 Months ago Karma: 0  
Thanks for responding!

I added the variable:

$reviewdate = "12 / 31 / 2007" to a Joomla article.


I'm trying to access that variable in the article template:

<php echo $reviewdate; ?>


I thought I needed to add: global $reviewdate;.

But, I don't know what function is being used by Joomla to display articles, so I don't know where to add global $reviewdate;
 
 
Last Edit: 2008/08/11 02:14 By plgard.
  The administrator has disabled public write access.
#631
kksou (Admin)
Admin
Posts: 1599
graph
User Online Now Click here to see the profile of this user
Re:php variables from Joomla Article to Template 3 Years, 9 Months ago Karma: 23  
You add it just before you use it:

<?php
global $reviewdate;
echo $reviewdate;
?>

Regards,
/kksou
 
  The administrator has disabled public write access.



Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2012. kksou.com. All Rights Reserved