Hi! I'm creating a series of TPL files to control my output in views.

After doing much research, it appears the way to display variables in TPL files is by pulling them out of the content array. What I've been doing is using Devel (and online resources) to find where these variables are stored.

So far, I've been able to display most of my content using outputs like these:

	$myBody = $content['body']['#items'][0]['value'];
	$myTitle = $fields['title']->content;
	$myAuthor = $row->field_field_author[0]['rendered']['#markup'];
	$myAuthoringOrg = $row->field_field_authoring_organization[0]['rendered']['#markup'];
	$myLink = $row->field_field_video_url[0]['rendered']['#markup'];

It's working out great so far! (Of course, in my real code, I'm adding a bunch of checks to see if the variables exist before assigning them.) The problem is, though, that I can't seem to figure out how to get the published date. I'm trying a bunch of strings and searching online and I can't find one that works.

How do I display the published date of a node using PHP in a TPL file?

Thanks!
Brendan

Comments

Jaypan’s picture

Depends on which template

bdparker’s picture

Does it? Ok. How do I find out how I approach this based on the template I have?

VM’s picture

you haven't stated which template (note tpl.php file NOT theme) you are working with.

bdparker’s picture

The actual name of my file is "views-view-fields--avideo_photo_and_video_videos.tpl.php".

VM’s picture

I suggest working with the devel.module

project =https://www.drupal.org/project/devel
docs = https://www.drupal.org/node/174575

bdparker’s picture

I am. I mentioned that in the question. "What I've been doing is using Devel (and online resources) to find where these variables are stored." Something I'm doing isn't working for me. Any advice?

VM’s picture

IIRC there isn't a 'published date' rather a submission date which is when the node is first saved and this is what is utilized in the node. To attach a date to when the 'published' checkbox was checked would require a custom module.