using a content block in several places on the same page

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
nathangaitch
Forum Members
Forum Members
Posts: 30
Joined: Fri Feb 20, 2009 9:10 am

using a content block in several places on the same page

Post by nathangaitch »

Hello all, I wonder if you can help:

I am trying to put together a template whereby I can use a simple piece of information, gathered from a one-line content block, in several places on the same page. For example, I want to be able to insert the same word in to a heading, a file name, as well as another location on the same page, which I would style differently, but the data is the same in each case.

It needs to be template driven, because I have a whole load of pages that I want to do this on, where the piece of info gets used several times on the page, but differs from page to page.

I've tried calling the same contentblock in the different places in the template, but that causes a parsing error. Global Content Blocks are no use to me, as the info has to be different on each page.

I'm stumped. I'm sure it must be possible, as CMSMS is so flexible, but I have no idea.

I hope you can help, and thanks very much for your time.

Nathan
Jos
Support Guru
Support Guru
Posts: 4020
Joined: Wed Sep 05, 2007 8:03 pm

Re: using a content block in several places on the same page

Post by Jos »

nathangaitch wrote:I've tried calling the same contentblock in the different places in the template, but that causes a parsing error.
Can you specify how the tag looks like and what the parsing error is?
nathangaitch
Forum Members
Forum Members
Posts: 30
Joined: Fri Feb 20, 2009 9:10 am

Re: using a content block in several places on the same page

Post by nathangaitch »

Hi Jos, Here is the information as far as I can get it for you:

The tag I'm using for the contentblock looks like this:

Code: Select all

{content block='songtitle' oneline='true'}
and when I try to put it in more than one place on the template, when I then go to the Pages section of the admin site and try to edit the page, it says (at the top of the editing page):

Code: Select all

An error occurred parsing content blocks (perhaps duplicated block names)
No default content block was detected in this template. Please ensure that you have a {content} tag in the page template.
The second line is particularly baffling, as there most definitely IS a {content} tag elsewhere in the template.

I'm running 1.9.4.2 "Faanui"

I hope this is useful info. I'm a bit of a beginner here, with no programming knowledge, so you might need to keep any answers in simple language please!

Many thanks again,
Nathan
Jos
Support Guru
Support Guru
Posts: 4020
Joined: Wed Sep 05, 2007 8:03 pm

Re: using a content block in several places on the same page

Post by Jos »

Yes, you can not use that tag more then once. It would generate multiple inputfields for the same field when you create/edit a page.

You can do it like this. Enter this code in your page template, somewhere beneath the </__body>

Code: Select all

{content block='songtitle' oneline='true' assign='songtitle'}
Now you can use the smarty variable 'songtitle' everywhere you want like this:

Code: Select all

{$songtitle}
With 'everywhere' I mean everywhere, but only not between </__body> and the {content block=..}. So you can even use it in the <head> section
nathangaitch
Forum Members
Forum Members
Posts: 30
Joined: Fri Feb 20, 2009 9:10 am

Re: using a content block in several places on the [SOLVED]

Post by nathangaitch »

Hey Jos,
You are a wonderful man, and your place in heaven is assured (Ironically spoken!)

I guessed it was probably something nice and simple, but would never have found it by myself.

Again, thanks so much for your time.

Best wishes,
Nathan
Jos
Support Guru
Support Guru
Posts: 4020
Joined: Wed Sep 05, 2007 8:03 pm

Re: using a content block in several places on the same page

Post by Jos »

;D great!
Post Reply

Return to “CMSMS Core”