Tags inside PHP
Posted: 19 June 2004 09:22 PM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  118
Joined  04-22-2002

I’ve searched and searched this site for the answer to what must be an obvious question…  I see how one places PHP inside EE tags.  What I do not see is how one might go about placing tag variables inside PHP.  I have placed all of my relevant PHP code between {exp:weblog:entries} tags but the field I would like to echo out just prints the curly braces and what’s between them, eg, the name of the field but not its value.

I know the codelet is reading the {exp:weblog:entries} tag because its reiterative count is the same as EE’s limit parameter that I set.

This question MUST have been answered before… perhaps it should go into the Knowledge Blog??

Profile
 
 
Posted: 20 June 2004 07:14 AM   [ Ignore ]   [ # 1 ]  
Grad Student
Rank
Total Posts:  81
Joined  04-18-2002

You did try adjusting the “Stage at which PHP should be parsed” radio’s in the template preferences, right?

Profile
 
 
Posted: 20 June 2004 09:58 AM   [ Ignore ]   [ # 2 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9853
Joined  06-19-2002

Relevant Knowledge-Blog entry.

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 01 September 2005 04:48 AM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  24
Joined  04-08-2005
Chris Curtis - 20 June 2004 09:58 AM

Relevant Knowledge-Blog entry.

That link seems to be dead.  Is the entry still available elsewhere, please?

 Signature 

Sorry, I was thinking about code.  What was that again?

Profile
 
 
Posted: 01 September 2005 05:10 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  831
Joined  04-17-2002

Depending on how you are using it, you might need to escape from the php for the EE tags. Can you give an example?

 Signature 

antipodean.org | uptheduff.org

Profile
 
 
Posted: 01 September 2005 05:56 AM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  24
Joined  04-08-2005
Tim Griffiths - 01 September 2005 05:10 AM

Depending on how you are using it, you might need to escape from the php for the EE tags. Can you give an example?

Here’s the sort of thing I’m trying to do.  The idea is to replace the standard output with the contents of the sorted $mainarray:
{exp:search:search_results}
<?php #assemble an array
$temparray = array(’{auto_path}’=>’{title}’);
$mainarray += $temparray;
?>
{/exp:search:search_results}
<?php #do array sort here ?>

That should produce lots of little PHP blocks which will be parsed on output, but it seems that the braces get evaluated as part of a malformed conditional/function call.  The parser then, as it should, rejects the whole thing. [sigh]  Ironically, the code produced if I turn off PHP parsing in the template is well-formed.

 Signature 

Sorry, I was thinking about code.  What was that again?

Profile
 
 
Posted: 01 September 2005 08:49 AM   [ Ignore ]   [ # 6 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12755
Joined  04-29-2002
Tim of Bluestorm - 01 September 2005 04:48 AM
Chris Curtis - 20 June 2004 09:58 AM

Relevant Knowledge-Blog entry.

That link seems to be dead.  Is the entry still available elsewhere, please?

Assuming this is what Chris was referring to:

How to I turn on PHP parsing for a template

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
Posted: 01 September 2005 09:00 AM   [ Ignore ]   [ # 7 ]  
Summer Student
Total Posts:  24
Joined  04-08-2005

Ah, then that wouldn’t be what I need.  downer

As you can see from the code above, I’m trying to generate lots of PHP code blocks that include EE tags as string values.  Is there any way to prevent the braces that surround the EE tags from being misinterpreted?

 Signature 

Sorry, I was thinking about code.  What was that again?

Profile
 
 
Posted: 01 September 2005 10:04 AM   [ Ignore ]   [ # 8 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  33269
Joined  05-14-2004

Have a look at this knowledge blog entry explaining input and output.

 Signature 
Profile
MSG
 
 
Posted: 01 September 2005 10:50 AM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  24
Joined  04-08-2005

That wasn’t the problem per se:  For some reason, the braces were being misinterpreted by the one of the core modules (hence my looking for “tags inside PHP”).

I’ve chucked my original code and written a new routine, which seems to do the job.  Here’s the bit that creates the array, in case it’s useful to anyone:

$crs = array({exp:search:search_results}’{exp:replacestring}{title}{/exp:replacestring}’ => ‘{exp:replacestring}{auto_path}{/exp:replacestring}’, {/exp:search:search_results} ‘theend’=>‘thatsallfolks’);
$ignoreme = array_pop($crs);

This lets me sort the links by path with asort(). 

My next job is to provide headings based on the links, but that’s a bit outside the scope of this thread. smile

 Signature 

Sorry, I was thinking about code.  What was that again?

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 66382 Total Logged-in Users: 52
Total Topics: 84699 Total Anonymous Users: 29
Total Replies: 454616 Total Guests: 238
Total Posts: 539315    
Members ( View Memberlist )