We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8960
    • 150 Posts
    Level: Beginner

    Here’s a tutorial I wrote on how to use TVs to accomplish MODx’s version of Custom Content Types. Please let me know if there’s a better way to accomplish true Custom Content Types, or if there’s a better way to accomplish what this tutorial covers.

    Created using TV’s and displayed using Chunks and Ditto (all MODx speak). So, in plain English, here’s how I did it:

    Step 1:
    Log into the MODx Manager and click on the menu RESOURCES --> MANAGE RESOURCES --> TEMPLATE VARIABLES

    I created new TVs by clicking on the New Template Variable link.



    **************************************************************
    **************************************************************
    Step 2:
    I named and created a new TV with each of the items that makes up a Bibliography (Author, Title, etc…). I chose text as the input type for all but the Date (I chose ‘date’ for that one, but text would work just fine) and Abstract (I chose textarea since I was going to input more than one line of text). Wash, rinse, repeat 5 times for the 5 items.



    **************************************************************
    **************************************************************
    Step 3:
    Next we move from the tab TV to Chunk and we create new Chunks. I created 3 Chunks here: bibliography (to display our TVs), and DittoBib (to work with MODx’s Ditto which redisplays content/articles), and DittoBibAlt (which Ditto will use as an alternate row like a table listing; all I added to this was a background color).



    **************************************************************
    **************************************************************
    Step 4:
    Here’s where we created the Chunk bibliography. What this is doing is calling up the 5 TVs I created and displaying them. I wrapped each TV in a HTML tag to give it some formatting on the frontend of the website (what visitors see). Note: you can use this Chunk ANYWHERE in MODx you want. All you have to do is add this to where you want it displayed: {{bibliography}}



    **************************************************************
    **************************************************************
    Step 5:
    This looks more complicated, but it’s not. Ditto wants to refer to a template to know how display content. This Chunk is my Ditto template (and can be used ANYWHERE in the site). The difference here is Ditto needs TVs called up with ‘tv’ in front of the TV name. So, while I call up TVs in step 4 like this, [*bibAuthor*] , I call up TVs in step 5 like this: [+tvbibAuthor+]. The other difference here is I linked the Title to the actual document.



    **************************************************************
    **************************************************************
    Step 6:
    Now for the content. We need a page to display the list of Bibliographies. So I make a new page, make it a container (a folder), give it a name (Bibliographies), and then I call up the Ditto template from step 5. In the Ditto call, I’m telling Ditto to start at document ID 71 (the page I’m creating now), and I also to tell it the name of my Ditto Template (also created in step 5). The result here is the page I gave you the link for at the very top of the email (which you probably read yesterday and are just now making it down this far).



    **************************************************************
    **************************************************************
    Step 7:
    Finally, an actual bibliography page is born. I created a new document under the document from step 6. I gave it the same title as the title for my publication. For the content, I only add the one line from step 4: {{bibliography}}. When I scroll down, I can see the 5 items we created in step 2, which are the content items for my bibliography. Fill in each of the 5 items, click on save, and then visit the link at the top of this email to see the results. Now, I just keep adding documents to create more bibliographies.



    TVs are very powerful. You can combine them in any fashion and they can take on any form/shape). I’m just showing you one use here and I didn’t take any screenshots of the final result, sorry. BTW, total time for me to figure all this out was 45 minutes, which is just as long as I’ve been typing this tutorial.