CMS Made Simple Forums
https://forum.cmsmadesimple.org/

Had a revelation about module tags. I am not a smart(y) man.
https://forum.cmsmadesimple.org/viewtopic.php?f=4&t=67743
Page 1 of 1

Author:  Simon66 [ Wed Sep 04, 2013 10:35 am ]
Post subject:  Had a revelation about module tags. I am not a smart(y) man.

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.
\$1:
{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
content.png [ 185.6 KiB | Viewed 4954 times ]

Author:  gocreative [ Tue Sep 10, 2013 6:18 am ]
Post subject:  Re: Had a revelation about module tags. I am not a smart(y)

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.

Author:  Simon66 [ Sat Sep 14, 2013 11:39 am ]
Post subject:  Re: Had a revelation about module tags. I am not a smart(y)

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:

\$1:
{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 4822 times ]

Author:  gocreative [ Sat Sep 14, 2013 10:53 pm ]
Post subject:  Re: Had a revelation about module tags. I am not a smart(y)

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.

Author:  calguy1000 [ Wed Mar 19, 2014 4:35 pm ]
Post subject:  Re: Had a revelation about module tags. I am not a smart(y)

@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:

\$1:
  {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).

Author:  gocreative [ Wed Mar 19, 2014 10:25 pm ]
Post subject:  Re: Had a revelation about module tags. I am not a smart(y)

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.

Author:  gocreative [ Mon Mar 24, 2014 11:08 pm ]
Post subject:  Re: Had a revelation about module tags. I am not a smart(y)

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.

Author:  zaidcrowe [ Tue Mar 25, 2014 10:38 am ]
Post subject:  Re: Had a revelation about module tags. I am not a smart(y)

@gocreative - if i understand you thats a part of Extended Content Blocks too, and is documented really simply in the module itself :)

Author:  gocreative [ Tue Mar 25, 2014 10:46 am ]
Post subject:  Re: Had a revelation about module tags. I am not a smart(y)

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.

Author:  zaidcrowe [ Tue Mar 25, 2014 10:57 am ]
Post subject:  Re: Had a revelation about module tags. I am not a smart(y)

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

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/