Had a revelation about module tags. I am not a smart(y) man.

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Locked
Simon66
Forum Members
Forum Members
Posts: 248
Joined: Wed Aug 29, 2007 4:36 am
Location: Sydney Australia

Had a revelation about module tags. I am not a smart(y) man.

Post by Simon66 »

Module Tags in the Content Area

The problem I've had, was that over the years I have always believed module call tags could be placed either in the content or the template. A lot of modules only function or function better when placed in the content.
This meant that I mixed a module call like this {FormBuilder form='contact'} with text (an address perhaps) in the content editor.

Based on this I've had clients call and tell me they accidentally deleted the "thing with the squiggly brackets". Not a huge problem, but not the slick user experience I try to create for my clients.

Here's my (very late) revelation:

I had overlooked using a second content tag. I put this at the top of my template.

Code: Select all

{content assign="ModuleTag" block="tag_content_block" label="Tag Content Block" wysiwyg="false" oneline="true" tab="options"}
So I made this second content tag single line, no wysiwyg and under the 'Options' tab. I don't give my clients permissions to see the options tag.

That's where I dump the module call tag {FormBuilder form='contact'}.

I then put this {$ModuleTag} in the template body above or below the {content} tag depending on what my client needs to edit.

So far no problems with this, but if anyone can see why this would be a bad idea please let me know.

Simon66
Attachments
content.png
gocreative
Power Poster
Power Poster
Posts: 265
Joined: Mon Mar 14, 2011 1:16 am
Location: Brisbane, Australia

Re: Had a revelation about module tags. I am not a smart(y)

Post by gocreative »

My method is to simply give them the option. For example, I'd create a custom content block called "show_formbuilder" which is a drop-down with values of "Yes" and "No". This is visible to the client so that they can turn something on or off.

In the page template, I then call it something like this:

{if $show_formbuilder eq 'Yes'}{formbuilder}{/if}

This avoids the problem of something being deleted but also allows the client to have more control over what is displayed on each page. The same principle could be applied to showing/hiding a sidebar or displaying a Google map etc.
Simon66
Forum Members
Forum Members
Posts: 248
Joined: Wed Aug 29, 2007 4:36 am
Location: Sydney Australia

Re: Had a revelation about module tags. I am not a smart(y)

Post by Simon66 »

Thanks for that, I've never used that method before.

The problem is I don't give my customers that much freedom. I like to keep the bit they edit very simple.

I have found that with the setup I posted above, it doesn't work with a summary/detail module.

So I modified to this:

Code: Select all

{content label="Tag Content Block" wysiwyg="false" oneline="true" tab="options"}

{content block="content2" label="Content 2"}
This puts the main content block under the options tab as a single line field - module calls go in here. This makes the summary/detail modules work perfectly.

The second content block called 'Content 2' appears on the main tab where the original content block was.

Any content entered here by the customer appears above the module on the page.

Simon66
Attachments
content2.png
content2.png (11.46 KiB) Viewed 6071 times
Last edited by Simon66 on Wed Sep 18, 2013 2:17 am, edited 1 time in total.
gocreative
Power Poster
Power Poster
Posts: 265
Joined: Mon Mar 14, 2011 1:16 am
Location: Brisbane, Australia

Re: Had a revelation about module tags. I am not a smart(y)

Post by gocreative »

I always throw those extra options I mentioned into a new page tab called "Design Features". Here I have options such as:

* Show sidebar
* Show random testimonial
* Show blog articles
* Show photo gallery (option to choose which gallery)
* Show contact form
* Show slider
* Show feature boxes
* Show breadcrumbs

The defaults I've set ensure that every new page is set up appropriately, and the client doesn't have to do a thing. But if they want the option, it's there. It makes it easier for me to set up specific layouts for clients and still only use one page template.

I don't like clients being able to control everything, but making their website as flexible and easy to use as possible is my number one goal.

In saying that, every developer's clients and needs are different, so do what works for you. I've just found this is a huge time-saver for myself and my clients.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Had a revelation about module tags. I am not a smart(y)

Post by calguy1000 »

@JohnBoyUK

It's pretty simple actually.

{content block='show_sidebar' oneline=true assign='show_sidebar' tab='options' label='Show the Sidebar'}

Now just some logic in your template:

Code: Select all

  {if $show_sidebar != ''}
     <div class="sidebar">
         ...
     </div>
  {/if}
  <div class="main_content">
      {content}
  </div>
Now. If you want it a bit more friendly than just a text field on the options tab, modules like CGContentUtilities allow you to create different block types (like a checkbox, or a dropdown).
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
gocreative
Power Poster
Power Poster
Posts: 265
Joined: Mon Mar 14, 2011 1:16 am
Location: Brisbane, Australia

Re: Had a revelation about module tags. I am not a smart(y)

Post by gocreative »

For what it's worth, I prefer the Extended Content Blocks module. In our sites, we assign these extra settings to a new "Features" tab within the page, since we don't allow clients to access the "Options" tab.
gocreative
Power Poster
Power Poster
Posts: 265
Joined: Mon Mar 14, 2011 1:16 am
Location: Brisbane, Australia

Re: Had a revelation about module tags. I am not a smart(y)

Post by gocreative »

There is a relatively easy way to do it using a module link function but I can't remember how to call it. Calguy may be better placed to help with that one.
zaidcrowe
Forum Members
Forum Members
Posts: 109
Joined: Wed Jun 10, 2009 3:43 pm

Re: Had a revelation about module tags. I am not a smart(y)

Post by zaidcrowe »

@gocreative - if i understand you thats a part of Extended Content Blocks too, and is documented really simply in the module itself :)
gocreative
Power Poster
Power Poster
Posts: 265
Joined: Mon Mar 14, 2011 1:16 am
Location: Brisbane, Australia

Re: Had a revelation about module tags. I am not a smart(y)

Post by gocreative »

Creating a drop-down list in ECB is easy. The part I can't remember is using a specific module content utility call (or writing a UDT) to dynamically populate the list of categories from the Showtime module.
zaidcrowe
Forum Members
Forum Members
Posts: 109
Joined: Wed Jun 10, 2009 3:43 pm

Re: Had a revelation about module tags. I am not a smart(y)

Post by zaidcrowe »

I've always dont this by writing my own udt that looks up against the appropriate table in the db
Locked

Return to “Tips and Tricks”