Including contextual banner adverts in sidebar for news story

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.
Locked
Anastasis

Including contextual banner adverts in sidebar for news story

Post by Anastasis »

I have organised our news stories so that they are displayed on a separate detail page. What I want to be able to do is place contextual banner adverts to the left of the news story content in the main sidebar based on the news story category.

What I cannot work out is how to do it.

The "Detail Template" tab in the news module contains the template needed to display the news content.

The News Story detail page is empty but is linked to a News Story template which provides the main outer HTML including the top banner for the website and the left-hand sidebar navigation.

It is on the sidebar that I want to place the contextual banner advert images based on the news story category, but how do I refer to the news story category in the News Story template?

I thought the solution was to merge the news module "Detail Template" and the news page template into one.

To do this I attached a blank template to the News Story detail page and put all of the code from the News Module "Detail Template" tab and the original News Story template into the News Story "Detail Template" tab, but that didn't work...

Hence the "Detail Template" tab in my news module contained the following:

1.  Site header and side navigation (which is where I would put conditional statements for outputting images based on the news category)

2. Code for processing the news story (what I had originally in the "Detail Template" tab)

3. Site footer

But as I said it didn't work. Am I misunderstanding something? The only way I can see is to access the category of the news story being displayed before it is displayed (if that makes sense!), but how do I do that?

TIA
Last edited by Anastasis on Thu May 31, 2007 3:41 pm, edited 1 time in total.
alby

Re: Including contextual banner adverts in sidebar for news story

Post by alby »

1. Very simple  :o

- Copy your template (of news page) in a new template (ex: detailnews).

- Add a new Global Content Block: news-banner

- In this global content block insert:
category}.jpg />

- Add in detailnews a {global_content name="news-banner"}

- Upload in /uploads/sub_directory/ [Name_category_news].jpg (case sensitive)

Alby
Anastasis

Re: Including contextual banner adverts in sidebar for news story

Post by Anastasis »

Sorry Alby

There must be something I am misunderstanding here.

As the news gets loaded in after the sidebar is loaded then at that point {$entry->category} is blank isn't it?

This is certainly what I find in my testing of this. If I put {$entry->category} in my global content block called "Navigation-Side" which is used in all templates, then in the home page I get a Smarty error saying: "unrecognized tag: $entry->category", but when I click through to a news story there is no error but a test: ">>{$entry->category}>category" is initialised but not populated. Only when the news content is displayed after the sidebar does "$entry->category" contain a value.

As I say maybe I am misunderstanding something or maybe there is another way around this. I will have a look again - would using the "capture" command maybe work if the news content is captured before the sidebar is displayed and then the content is displayed afterwards?
alby

Re: Including contextual banner adverts in sidebar for news story

Post by alby »

Anastasis wrote: This is certainly what I find in my testing of this. If I put {$entry->category} in my global content block called "Navigation-Side" which is used in all templates,
No, copy your template in a NEW template and add {global_content name="Navigation-Side"} in this only
Create a new page with THIS template and uncheck Show in menu (call for ex: newspage)
In your original template add detailpage parameter: {.... detailpage="newspage"}, now detail open newspage only
Now in "newspage" you have {$entry->category}

Alby
Anastasis

Re: Including contextual banner adverts in sidebar for news story

Post by Anastasis »

alby wrote: No, copy your template in a NEW template and add {global_content name="Navigation-Side"} in this only
Create a new page with THIS template and uncheck Show in menu (call for ex: newspage)
In your original template add detailpage parameter: {.... detailpage="newspage"}, now detail open newspage only
Now in "newspage" you have {$entry->category}

Alby
OK, thanks, but sorry though I am being a bit dense here and every way I try what I think you mean I am just not understanding where the different elements go. Perhaps I am not being clear in my explanation.
Locked

Return to “CMSMS Core”