I’m kind of new with modx, I think I’m starting to get a hold of it, but some features are still not quite clear to me. I know there must be a good use of them, but I just can’t figure out what to use in which case.
For example, I want to be able to diplay the Created by and Published Date on blog posts only, but not on other pages and articles. I installed PHx so I can now display the date, but I was just wondering what would be better to do that.
I know I can do this by creating another template which will contain the "author" and "published by" below the title and use that template for my blog posts.
But the question is, can this be done with template variables? TV’s are still not quite clear to me, so I don’t know their possibilities yet, but I suppose it would be simpler and better if this can be done with TV’s.
So how should I do that? Should I use another template with the date added, or is there a way to be done through TV’s?
-
☆ A M B ☆
- 24,524 Posts
It can be done with either different templates for blog/news pages, or with a TV and a common template. That’s the beauty and the beast of MODx; the beauty is you can do just about everything in several different ways, the beast is you have to make a decision which way will work best for you.
In this case, it’s just a matter of which will be easier for you/your users to work with. With a separate template, you won’t need to edit the TV. A bit of planning in the structure of the Document Tree will enable you to take advantage of the template inheritance feature, so all the blog/news pages will inherit a blog/news container document’s template.
If editing a TV for blog/news documents while otherwise just having the empty TV hanging around in the rest of the documents won’t be a problem, that might be the best way for you to go.
Now you could get fancy and make a snippet that will determine if the document being processed is a child of the blog/news section and output the desired fields if this is the case. This would give the best of both worlds, one template and no TVs hanging around, but requires more in the initial setup (writing the snippet). I think you could do much the same thing with PHx, but I’m not all that familiar with using it.