Page 1 of 1

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

Posted: Wed Sep 04, 2013 10:35 am
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

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

Posted: Tue Sep 10, 2013 6:18 am
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.

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

Posted: Sat Sep 14, 2013 11:39 am
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

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

Posted: Sat Sep 14, 2013 10:53 pm
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.

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

Posted: Wed Mar 19, 2014 4:35 pm
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).

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

Posted: Wed Mar 19, 2014 10:25 pm
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.

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

Posted: Mon Mar 24, 2014 11:08 pm
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.

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

Posted: Tue Mar 25, 2014 10:38 am
by zaidcrowe
@gocreative - if i understand you thats a part of Extended Content Blocks too, and is documented really simply in the module itself :)

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

Posted: Tue Mar 25, 2014 10:46 am
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.

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

Posted: Tue Mar 25, 2014 10:57 am
by zaidcrowe
I've always dont this by writing my own udt that looks up against the appropriate table in the db