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
using a content block in several places on the same page
-
- Forum Members
- Posts: 30
- Joined: Fri Feb 20, 2009 9:10 am
Re: using a content block in several places on the same page
Can you specify how the tag looks like and what the parsing error is?nathangaitch wrote:I've tried calling the same contentblock in the different places in the template, but that causes a parsing error.
-
- Forum Members
- Posts: 30
- Joined: Fri Feb 20, 2009 9:10 am
Re: using a content block in several places on the same page
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:
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):
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
The tag I'm using for the contentblock looks like this:
Code: Select all
{content block='songtitle' oneline='true'}
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.
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
Re: using a content block in several places on the same page
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>
Now you can use the smarty variable 'songtitle' everywhere you want like this:
With 'everywhere' I mean everywhere, but only not between </__body> and the {content block=..}. So you can even use it in the <head> section
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'}
Code: Select all
{$songtitle}
-
- Forum Members
- Posts: 30
- Joined: Fri Feb 20, 2009 9:10 am
Re: using a content block in several places on the [SOLVED]
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
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