php variables from Joomla Article to Template

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.
Locked
plgard
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Aug 07, 2008 5:36 am
Location: Midwestern United States

php variables from Joomla Article to Template

Post by plgard » Thu Aug 07, 2008 6:32 am

Sorry if this is in the wrong place!

If you had anything to do with the development of Joomla, THANKS. This thing is pretty amazing!

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: Select all

{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: Select all

{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}
So obviously something had to go wrong or I wouldn't be posting - - That went wrong!

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 hope I'm missing something simple, it would be nice if this is actually possible!

Any help would be great!

Thanks

Locked

Return to “Joomla! Coding 101”