EE Tag In A Plugin
Posted: 10 March 2005 07:22 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  283
Joined  12-22-2003

I want to assign the value of {entry_date} to a variable. I’m trying to use:

$var = {entry_date}

but I’m getting a parse error. What else do I need to do to assign the tag value correctly?

Profile
 
 
Posted: 10 March 2005 08:15 AM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7534
Joined  08-05-2002

I think it will be outputted as a string since we are doing a str_replace to get it in there, so try this:

$var = ‘{entry_date}’;

 Signature 
Profile
 
 
Posted: 10 March 2005 08:54 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  283
Joined  12-22-2003

Tried your suggestion, Paul. It doesn’t give me an error now. However…when I return the value of $var, it’s actually returning {entry_date} instead of the unix timestamp.

Profile
 
 
Posted: 10 March 2005 09:53 AM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  06-19-2002

Doug, please don’t post the same thing to multiple forums.  It’s a bit rude (a form of spamming), makes support more difficult, and makes it harder for other people to find threads with answers when they’re searching.

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 10 March 2005 10:04 AM   [ Ignore ]   [ # 4 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7534
Joined  08-05-2002

Hm, I don’t know where the other forum post is, so I will answer here.  Are you doing this with PHP on output?  It will not work on PHP on Input since entry_date will not be set yet.

 Signature 
Profile
 
 
Posted: 10 March 2005 10:07 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  283
Joined  12-22-2003

Sorry, Chris. It was unintentional. I had posted in the general forum before I realized that there was a forum for technical assistance.

Profile
 
 
Posted: 10 March 2005 10:23 AM   [ Ignore ]   [ # 6 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  283
Joined  12-22-2003

Yes, Paul…the template in question is set to parse PHP on output.

Profile
 
 
Posted: 10 March 2005 10:24 AM   [ Ignore ]   [ # 7 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7534
Joined  08-05-2002

And this is in a {exp:weblog:entries} tag, right?  I tested this last night and it worked, or so it seemed.

 Signature 
Profile
 
 
Posted: 10 March 2005 10:27 AM   [ Ignore ]   [ # 8 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  283
Joined  12-22-2003

Yes it is.

Profile
 
 
Posted: 10 March 2005 10:32 AM   [ Ignore ]   [ # 9 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7534
Joined  08-05-2002

OK, this is what I have in my weblog/index template’s {exp:weblog:entries} tag with that template having PHP on Output set in the Template Preferences:

<?php

$date = ‘{entry_date}’;

echo “<p>Entry Date: $date</p>”;

?>

Outputs exactly what I expect.

 Signature 
Profile
 
 
Posted: 10 March 2005 10:44 AM   [ Ignore ]   [ # 10 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  283
Joined  12-22-2003

Here’s the relevant portion of code that I have in my plugin:

<?php

class Post_time

{

var $return_data = "";

  function
Post_time()

  
{

  
global $TMPL;

  
$parameter = $TMPL->fetch_param('entry');

  if (
$parameter == "entry")
    
$time_post = '{entry_date}'; /* unix time of post */
  
else if ($parameter == "comment")
    
$time_post = '{comment_date}'; /* unix time of comment */
  
  
$this->return_data = $time_post;

  
}

}

?>

Profile
 
 
Posted: 10 March 2005 10:53 AM   [ Ignore ]   [ # 11 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7534
Joined  08-05-2002

You’re putting this into a plugin?  Oh, I thought you were putting PHP code in a template.

Um, well, um…that’s not going to work then.  What are you trying to do?

 Signature 
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: 64978 Total Logged-in Users: 21
Total Topics: 82016 Total Anonymous Users: 22
Total Replies: 440814 Total Guests: 189
Total Posts: 522830    
Members ( View Memberlist )