CGBlog : Fundamental misunderstanding

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
naturelab
Forum Members
Forum Members
Posts: 169
Joined: Thu Oct 15, 2009 11:11 am

CGBlog : Fundamental misunderstanding

Post by naturelab »

I have a fundamental problem understanding how the CGBlog should work.
I realise that this question may sound very stupid, but here goes...

I have a 2 column layout, A category navigation in the small left hand column and the summary / detail to appear in the right hand column.
All of the blogs ( news ) should appear in the top level section / page called "NEWS". ie I have one page set up called NEWS.

I also have pretty URLS up and running correctly.

Code: Select all

{CGBlog action="browsecat" browsecattemplate="Sample"}
Which lists the category navigation ( as required )

Code: Select all

{CGBlog action="archive"}
Which creates the archive navigation ( as required )

In the main content <div> I have :-

Code: Select all

{CGBlog action="default" number="5"}
Which lists the first FIVE articles, as teasers.

So far so good.

When I click on one of the articles, it displays the article correctly, BUT it still displays the ( FIVE articles, as teasers ) underneath ( which is NOT required )

I need to get rid of the teasers. They should ONLY appear on the news homepage.
In the options for CGBlog, I have :-

Default detail page (if no page id is specified on the URL): set to NEWS
I also have
Default summary page (if no page id is specified on the URL): set to NEWS

I also have

Prefix to use on all URLS from the blog module: set to "NEWS"

I have experimented a bit with using "detailpage", but don't see the wisdom in having a separate page called "newsdetail" or similar.
Also, when I did this, my url would change to "www.mysite/newsdetail" and the page title etc will be "newsdetail"

I am seriously missing something here...

Could someone put me out of my misery ? Please ?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: CGBlog : Fundamental misunderstanding

Post by calguy1000 »

This is not a problem specifically with CGBlog, it applies equally to all of the modules in CMSMS.. and comes down to a fundamental thing in how CMSMS works.

In CMSMS you create a page template with a number of areas in them... one of these areas (usually surrounded by a div) is {content} the default content block. You may also create other content blocks, or call modules directly from this page template. For now lets assume that you've added additional content blocks like {content block='left_sidebar'}. This page template controls the layout of each page that uses that template. Your (simplified) page template probably looks like:

Code: Select all

<__html>
<head>
<title>{sitename}</title>
{metadata}
</__body>
<div class="header">...</div>
<div class="main_container">
<div class="sidebar">
{content block='sidebar'}
</div>
</div class="main_content">
{content}
</div>
<div class='clearb'></div>
</div>
<__body>
</__html>
Next you create a page (which has it's own unique alias and page id, and addressable url). specify the template you created above and start filling in content. In your example you want content in the left sidebar to show a list of blog categories, followed by an archive view, followed by a teaser.... by default in this page you probably want to display the latest blog article. so you do something like this:

In the sidebar block:

Code: Select all

  {CGBlog action='categorylist'}
  {CGBlog action='archive'}
  {CGBlog limit=5 summarytemplate='teaser'}
in the main content block

Code: Select all

{CGBlog}
---
So far, so good. You have now generated some content for this page...but that's all that has been done. You have requested that the CGBlog module be called 4 different times, to display four different sets of data (or display the same data 4 different ways). Some of these calls will generate links (either using some of the parameters you specified in the calls, or the settings in the modules) to a detail page, or to a summery view that is somehow filtered. The link generated contains enough information that a page id can somehow be determined, and what subset of data to display. By default the system will use the default content block {content} to display that data when you click on the link.

Again, so far so good. You have clicked on one of the links provided, and because the system found the same page id, and therefore the same template the system finds the content block for the sidebar and parses it, and displays the requested content again. And also, because the URL contained information that could be read by the CGBlog module, the default content block is replaced with content according to the criteria specified in the url and the module preferences. That's it. You have told the system what to display. There is no automatic intelligence telling the system that just because you clicked on a category link, or an archive link that you no longer want to display the sidebar, or portions of the sidebar, or to exclude one certain article from the list, or to display it differently.... that type of behavior cannot be built in because each site will behave differently.

This is where you need to start expanding your knowledge. You need to understand smarty, how it works, and how you can add logic to control the display of certain things. And you also need to understand how CMSMS works a bit better (splitting page templates up and processing the body first, which essentially makes each page template into 3), and also the ramifications of putting certain types of logic into your templates (caching is no longer possible, etc).

Now... for the cheap and easy way of making what you want work I would:
a: Modify your page template to be like this (abridged)

Code: Select all

...
</__body>
{content assign='my_content'}
<div class="header">...</div>
<div class="main_container">
<div class="sidebar">
{content block='sidebar'}
</div>
</div class="main_content">
{$my_content}
</div>
<div class='clearb'></div>
</div>
<__body>
...
Note how {content assign='my_content} is called BEFORE the sidebar. it's output is captured into the smarty variable called {$my_content} and we just display that where we want it.

b: Modify your CGBlog detail template (or whatever other templates where you want to hide the teaser) to add something like

Code: Select all

{assign var='hide_teaser' value=1}
This sets a smarty variable indicating that the teaser stuff should be hidden.

c: In the page template, or the page content, or GCB where you are displaying the teaser list in the sidebar change it to something like:

Code: Select all

{CGBlog action='categorylist'}
{CGblog action='archive'}
{if !isset($hide_teaser)}
{CGBlog limit=5}
{/if}
This simply says, if the hide_teaser variable is not set... then we are clear to display the teaser stuff.

d: Disable caching in that page... and if your calls to CGBlog are in the template, on all pages that use that template.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
naturelab
Forum Members
Forum Members
Posts: 169
Joined: Thu Oct 15, 2009 11:11 am

Re: CGBlog : Fundamental misunderstanding

Post by naturelab »

Hi :- Thanks for spending the time on such a comprehensive reply. Much appreciated. I've actually been using CMSMS for nearly 5 years now, but this post just highlights the point that in certain areas I have "started to run before I could walk". I am completely self taught ( A designer really ) and have actually done some quite complicated ( for me anyway :) ) stuff with Smarty template logic, in fact, after your reply, I'm wondering if I have too much logic in some of my templates.

I got the blog section working - thanks - very simple solution. I had actually been really over-complicating things and this now makes sense.

The part of your reply that I found really interesting...
This is where you need to start expanding your knowledge. You need to understand smarty, how it works, and how you can add logic to control the display of certain things. And you also need to understand how CMSMS works a bit better (splitting page templates up and processing the body first, which essentially makes each page template into 3), and also the ramifications of putting certain types of logic into your templates (caching is no longer possible, etc).
As I said, I already do quite a bit of logic to display parts of the template, but, I had completely over looked the way the template is processed ( stuff I probably should have learned first ). For anyone else reading who is curious, I found this post by Calguy from a few years back, expanding on this ( http://forum.cmsmadesimple.org/viewtopi ... 98#p203281 ) .

Although possibly beyond the cope of this post, I'm really keen to find out what you mean by :-
the ramifications of putting certain types of logic into your templates (caching is no longer possible, etc).
How much logic is too much logic in a template. I tend to use ONE template to do everything, so they are generally fairly large. Is this bad practice ?
What type of logic to avoid in my templates.
Also, I never considered page caching either.

Anyway, I really appreciate your reply and the help offered on the whole from the CMSMS community.
Post Reply

Return to “Modules/Add-Ons”