Hello,
I have been reading a bit about MODx after using Joomla! for previous projects and wanting something a bit more flexible.
I am missing a concept though I think. With Joomla, you have areas and modules assigned to the area per menu and with this you can define what modules appear on what pages.
I can’t see how to accomplish the same thing with MODx templates. If I have a menu that I want to only appear on particular pages, or the login box, or some other dynamic content.
I can see that I could assign different templates to different documents, but I would end up with a lot of repetition - lots of template files that are mostly the same but with small differences. This would make maintenance a problem.
What am I missing?
Many thanks,
Paul
Warning! Once you get to know modx you will never want to use joomla again!!
http://wiki.modxcms.com/index.php/MODx_Instructional_Videos
//...The answer is that you can put snippet calls inside docs, chunks and customised fields (tv’s) and even inside snippet calls themselves.
Thanks to tv’s there is no need of create a new template every time. I have an [*upperContent*] inside my template’s <head></head>
that is I have a field added for all my docs settings where I can load scripts. The built in...
More:
http://wiki.modxcms.com/index.php/Placeholders_used_by_MODx_Pages_and_Templates
http://wiki.modxcms.com/index.php/Beginner%27s_Guide_to_MODx
As mrhaw suggest, what you want to do is very common and usually ver easy in MODx once you get used to it. Every document has a "content" field and you can embed pretty much anything you want in the content section (or elsewhere) in various ways.
The Wayfinder snippet, for example, generates dynamic menus and you can just put [[Wayfinder? &startId=`0`]] or something similar wherever you want one.
See the site in my sig. for a look at how MODx works.
Thanks for the replies guys. I suspect that Joomla has narrowed my way of thinking, as I still don’t quite "get it".
Perhaps an example? Lets say I have a basic two column layout - menu and other stuff in a sidebar in a left div, and page content in the main div.
So my "content" placeholder sits in the the main div. What I want to do is control what appears in the sidebar, dependent on which page is selected.
So lets say I have wayfinder in the sidebar, starting from id zero, and it shows ten links to ten documents. Now lets say that for some of these documents (1-5), I want wayfinder to remain in the sidebar if clicked, and for other pages (6-10), I want wayfinder to just not be there.
With joomla, the wayfinder menu would be a module, and I would just select the menu items I want the module to appear on - I would say that the module only appears on items 1-5.
How do I do something similar? I can put the wayfinder snippet call into each document that needs it I suppose, but then this means putting layout information into the document, which doesn’t seem "right".
Thanks...
You could either then create a new template for docs that has a very different layout or you can
put a [*sidebar*] tv in one template and have it output default value {{chunk01}} then for the pages
that will not show the chunk just delete this text {{chunk01}} in the field or call another chunk 02, 03...
This can be done in extremly many ways... :)
//Another way for instance --->
http://wiki.modxcms.com/index.php/%40CHUNK_Binding
The key is whether there’s something systematic about which documents you want the menu on. If not, you really don’t have much choice but to either put it in by hand on the pages where you want it, or use two different templates -- one with and one without the menu.
@mrhaw:
Aaah, right.
Yeah I see. Ok, I’ll try that but if you feel like posting other methods, go ahead!
@BobRay
Yeah I see. The "menu" was just an example, and I realise I can structure the menu so that wayfinder can be clever about what it shows, but what about something else.. Like a set of external links that should only appear in the sidebar if I am on a particular page? Or if I’d want to put a login snippet on a couple of pages? mrhaws suggestion would work for these scenarios, with some tv/chunk management for each page.
Or when you said "systematic", were you talking about something else I might not be aware of yet?
Hmm...
Lets say I had a series of chunks: main_menu, other_menu, login, related
Could I have a tv called "sidebar" that contained one or more of these chunk names for each document, and in the template have php iterate the list and include the chunks specified?
hey paul,
i moved from joomla too. so I think i understand.
You either want to:
1. allow the user to choose which items appear on individual pages
2. choose yourself which items show per page (and this wont change much).
For #1, You can use chunks as TV’s. It let’s the user choose which items to show on the page via a checkbox. Here’s a wiki item about it:
http://wiki.modxcms.com/index.php/Create_TV-Based_Chunks
For #2, I use phx. You can do something like [*id:is=`4`:or:is=`5`:then=`{{ChunkToShow}}`*] . You could also create a TV checkbox called showSubmenu then do [*showSubMenu:is=`1`:then=`{{ChunkToShow}}`*]
phx is documented here and VERY handy for one template with multiple options. I use it on every site.
http://wiki.modxcms.com/index.php/PHx
You pretty much can throw away the joomla module concept. Instead think of TV’s as ’module parameters’. They are per page instead of per site. You can set a default option, but allow it to be overwritten per page.
I outsource most joomla work now (or convert em to modx) because it makes it easier for me and clients.
You learn fast! 8)
The next step from here is PHx:
http://wiki.modxcms.com/index.php/PHx
and snippets/plugins usage - I.e. PHP functions. And maybe:
http://wiki.modxcms.com/index.php/Create_TV-Based_Chunks
The best way of learning is try and search. Search Wiki, forum and the repository. Whatever you want to accomplish
the chances are somebody else has already gone for it!
Modx is pure freedom of choice! 8)
//LOL!! I didnt see above posting!