Hello,
I have a chunk, that give me the summary of a news and a link to see the complete news.
[[Ditto? &parents=`3` &summarize=`4 &display=`4` &truncLen=`15` &tpl=`contenue_nouvelles` &extenders=`summary` &truncText=`Read More` &paginate=`1` &paginateAlwaysShowLinks=`0`]]
The thing is, everything is working but when the user clicks on "Read More", it does not give him the title, author, etc. I just want to know if it’s possible to call a chunk, when that user clicks on "Read More", in order to format the page correctly...
Thanks..
-
☆ A M B ☆
- 24,524 Posts
So if I understand your explanation correctly the "read more" is a link to the actual page? If this is the case, then you’ll need a snippet on the individual document to display that information on its page.
Of course, for the title you can use [*pagetitle*], [*longtitle*], and any of the rest of the document’s variables, as well as any custom template variables you may have.
But for the author, you’ll need a snippet to get the author’s name from the user_attributes table of the database, since [*createdby*] only returns the author’s id number. There may be such a snippet available in the add-ons repository; I’m not sure about that.
Similarly with the date, since that’s stored as a UNIX timestamp and needs to be converted.
Hello,
First of all, thanks for your answer.
The thing is that, it may change everytime. As... it’s like the "News System". So whenever someone makes a news, it’ll do the summary of the news and include a link ("Read More"). When that person clicks "Read More", it only shows the (content), of the news. Is there a way to make it like if it’s a Document in my "News Folder", that it always use the same pattern?
Thanks!
-
☆ A M B ☆
- 24,524 Posts
That depends on the template you use for these news documents (I don’t mean the chunk-tpl you use for the Ditto display). You can put anything in the way of MODx tags you want in the template.
For example, you can have in the template
...</head><body>
<h1>[*pagetitle*]</h1>
<h2>[*longtitle*]</h2>
<span id="author">By [[PageAuthor]]</span><span id="date">[[PageDate]]</span>
[*#content*]
</body></html>
The PageAuthor snippet would get the author’s name from the database using the createdby value, and the PageDate snippet would pretty-print the createdon timestamp. Style with the template’s css file and you’re all set.
Hello,
Awesome, everything is working... except the PageDate, I assume I have to create that snippet, right?
-
☆ A M B ☆
- 24,524 Posts
The createdon timestamp is what you need to modify. It’s a standard UNIX timestamp, so either phx or a snippet can convert it to a human-understandable form.
<?php
$date = date("F j, Y", $modx->documentObject['createdon']);
return $date;
?>
http://il2.php.net/manual/en/function.date.php