MODx = Wodrpess + Joomla [feature]
- Revolution (Future of MODx)
- Evolution (Classic Codebase)
I think Evolution is the best to start
What is MODX Evolution ?
MODX Evolution is a Content Management System and platform for building websites and web applications. It is ideal for small and large scale projects alike. MODX is used by both non-programmers and programmers to build web solutions that can be easily managed by end users.
Manage Elements:
- Templates Elements
- Templates Variables
- Chunks
- Snippets
- Plugins
Category: Snippets
Snippets are one of the most useful features of the MODx system. They are small pieces (snippets) of PHP code that can be used to create menu systems, blog archives, comment systems, image galleries, and anything else you can imagine.
Why the name Snippet? One of the definitions of the word snippet is actually "a short reusable piece of computer source code". Some people have a hard time distinguishing this from a "chunk", so a helpful mnemonic might lie in the p's… as in PHP, e.g. sni-P(h)P-et.
This category contains articles with information about snippets. Snippet is used as a function.
Re: Two separate navigation sections. How?
Hi Bluegum. Pleth posted while I was typing this, but I'm going to post anyway to expand on Pleth's post. I'm going to assume your document tree looks something like this:
Home
Page 1
- Link 1
- Link 2
- Link 3
- Link 4
Page 2
Page 3
Page 4
And I'm also going to assume that you want your top menu to show all the first level links, and your sidebar menu to show the second level links. Please correct me if I'm wrong.
In that case, your top Wayfinder call should look something like this:
CODE:
[!Wayfinder? &startId=`0` &level=`1`!]
Your side bar Wayfinder call will look different depending on exactly what you want it to do. If you only want it to show the same menu on each page, then your call should look something like this:
CODE:
[!Wayfinder? &startId=`2` &level=`0`!]
Your &startId value of course depends on which ID you want your menu to start from.
If you want it to show a different menu depending on which page you're on, your call should look something like this:
CODE:
[!Wayfinder? &startId=`[[UltimateParent]]` &level=`0`!]
Adding MODx Tags
To begin with, we can personalize the page's title with our site's name and the name of the page:
<title>[(site_name)] – [*pagetitle*]</title>
These tags in the head of your template will display something like "MODx Content Management System – Adding MODx Tags" in the title bar of the browser.
The "site_name" is taken from the name that was configured for your site in the System Configuration menu. The "pagetitle" is the Title you gave the document when you created it.
The next thing we want to do is have the document's content appear in the main part of our page. Add the
[*content*]
tag where the content should appear:
<div id="content">
<h1>[*longtitle*]</h1>
[*content*]
</div>
You will also see that the "longtitle" was added before the "content", so every page will have a customized subheading. The "longtitle" is taken from the Long Title field when you created the document. The "content" is the text you entered in the Document content editor when you created the document.
And finally, in the footer, you may want to have your site's name and email address:
<div id="footer">Copyright © <a href="mailto:[(emailsender)]">[(site_name)]</a> 2005</div>
Both of these values are taken from the database and were set in the System Configuration menu.
àThe core of any templating or content management system is the way it creates blocks of different kinds to separate the presentation of content from the creation of the content. MODx uses simple tags to create content that an editor can insert into a document without having to worry about how that content is created.
MODx Tags give you a simple, powerful way to include more variable content into your web pages.
Tags are replaced with the content they output. Here are a few examples:
- [[snippet]] or [!snippet!] for non-caching snippets Inserts the output of a snippet named 'snippet' into your page.
- [(setting)] Inserts the value of a site-wide setting named 'setting' into your page.
- [*resourceField/TV*] Inserts various blocks of content specific to the page being displayed.
- [^timing^] Shows how long it took to create the current page.
- [~link~] Makes a link to another document in your MODx site.
- { {chunk} } Inserts a chunk of HTML into your page.
- [+placeholder+] Acts as a placeholder for content generated by a snippet. Usually used in a chunk specified in an argument of the snippet to format the snippet's output.
Snippets
To execute snippets, insert the snippet's name in the snippet tag where you want the snippet's output to appear in your document or template. For example, [[MySnippet]]
Snippets are simply raw PHP code whose output is displayed in the location where the snippet tag is placed. For more information see Adding Snippets, as well as Document Caching, in the Designer's Guide.
Snippets are simply raw PHP code whose output is displayed in the location where the snippet tag is placed. For more information see Adding Snippets, as well as Document Caching, in the Designer's Guide.
Template Variables
TVs are a powerful method of inserting blocks of content specific to the page being displayed. They take two basic forms:
1. TVs can display basic document attributes, which are found in the MODx database in the table (PREFIX)site_content table in the MODx database where (PREFIX) is your table prefix.
These are the most commonly used document attributes:
- [*pagetitle*] - the title of the document
- [*longtitle*] - the long title of the document
- [*introtext*] - the summary of the document
- [*content*] - the content of the document
2. TVs can be programmed to generate widgetssuch as tickers, sliders, marquees, and data grids displaying the results of database queries. They can generate Rich Text Editors for user comments or forum entries.
With TVs, you don't need to be concerned about how these things are created, all you need to do is insert the TV tag where you want the widget to appear in your page.
Many TVs can even be customized for a specific document at the same time you are editing the document. They can provide lists or options you can select to apply to the document you are editing.
For more information see Template Variables in the documentation.
Links
To insert a link to another document within your MODx site, simply put the id number of the document in the link tag. For example, [123] will create a link to the document with ID 123.
Once MODx starts parsing the document, it will automatically select the best URL to create for this document, where 'alias' has precedence over 'friendly urls', which have precendence over 'index.php?id=123' style links. You can combine this with other tags, so [(site_start)] will output the URL for your site start page.
Chunks
Chunks contain plain text, usually HTML code, which will not be parsed by MODx, but simply inserted into the page.
They are very convenient for holding general content, such as for a page footer, that is to appear on all pages of a site. For example, if your footer contains your telephone number, and your number changes, you only have to make the change in the chunk, and not on every page on the site!
By using combinations of snippets, TVs and chunks, you can make your site pretty flexible! For example, you could have a snippet which outputs the tags for a chunk, which can contain tags for other snippets.
Chunks are also used to contain lists of options for TVs, and the same chunk can be included into any number of TVs to provide the same options (@CHUNK binding).
For more information about Chunks, see Chunks in the documentation.
Placeholders
The most common use for placeholders is to position the output of a snippet. An example of this can be seen in the NewsListing snippet's default template:
- <div class="nl_summaryPost">
- <h3><a href="[+id+]">+title+</a></h3>
- <div>+summary+</div>
- <p>+link+</p>
- <div style="text-align:right;">by <strong>+author+</strong> on +date+</div>
- </div>
A placeholder can be used anywhere in any HTML code where you wish that particular piece of a snippet's output to appear. A good example of that is the Personalize snippet. It merely returns the user's name, and can be used either as a normal snippet or as a placeholder. You can put the snippet once in your template or document, then put the placeholder in as many places as you like, such as in a greeting at the top of the page, and in the "logout" section of the weblogin snippet's template.
The (almost) Complete Guide to Creating Menus in MODx Using Wayfinder :
Wayfinder is a MODx snippet that easily creates highly dynamic and flexible navigational menus using unordered lists. You can even use Wayfinder to output tables, divs, definition lists, ordered lists, etc. In this guide, however, we will only be concerned with unordered lists.
Continue…
No comments:
Post a Comment