How to control the article separator for each article

Your code modifications and patches you want to share with others.
Locked
auxband
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Sun Feb 15, 2009 9:32 pm

How to control the article separator for each article

Post by auxband » Sat Feb 28, 2009 3:16 am

I don't think a little tutorial specific to the article separator has been created yet (at least I couldn't find it) but if it has, sorry.

Anyway, in my pursuit to make use of the article separator but to not have it show up under every article (as opposed to actually separating two articles), I eventually found my solution by adding the article separator as an advanced parameter at the article level (and also as a global parameter for all articles).

It involves hacking two core xml files and a template override of a php file (if there's a way to override admin files instead of hacking the core ones, please let me know because I couldn't find much info on this when I searched around).




Here's how to add the article separator as an advanced parameter:

1. Open up the article.xml file in the following directory

administrator\components\com_content\models

Under the <params group="advanced"> tag, you'll see the advanced parameters you're used to seeing (look where it says labels=).


2. Add the following code wherever you'd like the article separator parameter to appear:

Code: Select all

<param name="show_article_separator" type="list" default="" label="Article Separator" description="PARAMARTICLESEPARATOR">
	<option value="">Use Global</option>
	<option value="0">Hide</option>
	<option value="1">Show</option>
</param>
For reference, I added mine between the "Email Icon" and "Content language" parameters.


3. Then save the file (do not change the file name).




Here's how to add the article separator as a global parameter:

1. Open up the config.xml file in the following directory

administrator\components\com_content


2. Add the following code wherever you'd like the article separator parameter to appear:

Code: Select all

<param name="show_article_separator" type="radio" default="1" label="Article Separator" description="PARAMARTICLESEPARATOR">
	<option value="0">Hide</option>
	<option value="1">Show</option>
</param>
I added mine between the "Email Icon" and "Hits" parameters.


3. Then save the file (do not change the file name).




Here's how to modify the code that calls the article separator so that it's now controlled by the parameters you just created (and also how to save it as a template override):

1. Open up the blog_item.php file in the following directory

components\com_content\views\section\tmpl

IMPORTANT: if you're already using the blog_item.php file for another override, make sure you open up this file in your override directory and not the one above.


2. Locate the following code (at the bottom of the file):

Code: Select all

<span class="article_separator">&nbsp;</span>

3. Replace the above code with the following:

Code: Select all

<?php if ($this->item->params->get('show_article_separator')) :
	echo '<span class="article_separator">&nbsp;</span>'; 
endif; ?>

4. Then save the file (do not change the file name) in the following directory

templates\[whatever your template name is]\html\com_content\section




Now if you go to your article manager and check either the global configuration there or the advanced parameters within an article, you should see the article separator as an option.

Again, if there's a way to override admin files instead of hacking the core ones, please let me know.

Thanks,
Arthur

JoshuaLewis
Joomla! Apprentice
Joomla! Apprentice
Posts: 34
Joined: Sat Feb 14, 2009 10:42 pm
Location: Houston TX, USA
Contact:

Re: How to control the article separator for each article

Post by JoshuaLewis » Fri Mar 27, 2009 8:35 pm

auxband wrote:Again, if there's a way to override admin files instead of hacking the core ones, please let me know.
Arthur
Have you learned anything new about how to create this kind of override? I've been trying to figure the same thing out and haven't found much either.

I did come across a link to this - http://community.joomla.org/blogs/commu ... -html.html - but it's not exactly the detailed tutorial I was hopping for.

jeroenduller
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Mon Apr 12, 2010 9:35 am

Re: How to control the article separator for each article

Post by jeroenduller » Mon Apr 12, 2010 9:46 am

4. Then save the file (do not change the file name) in the following directory

templates\[whatever your template name is]\html\com_content\section
This directory does not exist in my template. When i create it myself, it does not affect the appearance of the seperator.

I also overwrote the original file, but also nothing happens in joomla 1.5.15

Jim the Chin
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 230
Joined: Mon Apr 10, 2006 12:15 pm
Location: Cromer, Norfolk, UK

Re: How to control the article separator for each article

Post by Jim the Chin » Mon Aug 09, 2010 2:15 pm

Hello

Just like jeroenduller, I can't get rid of a separator, even trying your method, auxband.

The separator does a good job on a category blog layout but the line beneath the last item isn't needed and looks wrong.

Any more suggestions, please?
Signature rules http://forum.joomla.org/viewtopic.php?f=8&t=65
Only exact urls allowed

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11614
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: How to control the article separator for each article

Post by ooffick » Mon Aug 09, 2010 3:18 pm

Did you try any template overwrites?
Does the maximum number of items in the menu item is the same or smaller then the number of frontpage items?

Olaf
Olaf Offick - Global Moderator
learnskills.org

Jim the Chin
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 230
Joined: Mon Apr 10, 2006 12:15 pm
Location: Cromer, Norfolk, UK

Re: How to control the article separator for each article

Post by Jim the Chin » Mon Aug 09, 2010 3:58 pm

ooffick wrote:Did you try any template overwrites?
I'm unsure what template overwrites means? I did try creating a new folder, as jeroenduller did, and saving the modified blog_item.php file to it... doesn't work.
ooffick wrote:Does the maximum number of items in the menu item is the same or smaller then the number of frontpage items?
No. I checked it in various ways... doesn't work
Signature rules http://forum.joomla.org/viewtopic.php?f=8&t=65
Only exact urls allowed

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11614
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: How to control the article separator for each article

Post by ooffick » Mon Aug 09, 2010 5:01 pm

ok, which template are you using?
Do you have a /.../templates/[your template]/html/com_content/category/blog_item.php file?

Olaf
Olaf Offick - Global Moderator
learnskills.org

Jim the Chin
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 230
Joined: Mon Apr 10, 2006 12:15 pm
Location: Cromer, Norfolk, UK

Re: How to control the article separator for each article

Post by Jim the Chin » Tue Aug 10, 2010 4:44 am

ooffick wrote:ok, which template are you using?
Do you have a /.../templates/[your template]/html/com_content/category/blog_item.php file?
I'm using a very much customised template - http://stgileshousehotel.com/

Now, the previous instruction was to put the file in templates\[whatever your template name is]\html\com_content\section - but now I've used your suggestion /category - it all works fine!

Thank you thank you!
Signature rules http://forum.joomla.org/viewtopic.php?f=8&t=65
Only exact urls allowed

Renegade_Mtl
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Tue Sep 28, 2010 3:39 pm

Re: How to control the article separator for each article

Post by Renegade_Mtl » Fri Oct 01, 2010 2:55 pm

Ive been trying to get this to work... and nothing works... ive located every single blog_item.php
and added the code... Ive even tested removing completely the blog_item.php files on the whole entire site...

I did this with the idea that eventually the site would crash... but It never did.. all the blog_item.php files are removed and the articles still show.. and the seperator still lives on...

Now if i only wanted to remove the seperator i would just edit the css but i like the idea of having it as a global function...

any idea?? i really dont get why everything still works with all those files removed... why are they even there if there not getting called somewhere?

:-[

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11614
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: How to control the article separator for each article

Post by ooffick » Wed Oct 06, 2010 9:05 am

Are you looking into the correct template?
Which View are you using? Are you displaying the frontpage blog, the category blog or the section blog?

Olaf
Olaf Offick - Global Moderator
learnskills.org

Renegade_Mtl
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Tue Sep 28, 2010 3:39 pm

Re: How to control the article separator for each article

Post by Renegade_Mtl » Wed Oct 06, 2010 1:25 pm

Oh my, Im talking about the article seperator for the frontpage. Unless that is what you are referring to as the "blog". Im talking about 3-4 articles that are on frontpage... I can style the seperator in css, If i delete the css it goes away, but when I edit the files as mentioned nothing happens, Yes its the correct template files..

Any ideas?

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11614
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: How to control the article separator for each article

Post by ooffick » Wed Oct 06, 2010 5:39 pm

The frontpage view would be using this template overwrite:
/.../templates/[your template]/html/com_content/frontpage/default_item.php

Olaf
Olaf Offick - Global Moderator
learnskills.org

Renegade_Mtl
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Tue Sep 28, 2010 3:39 pm

Re: How to control the article separator for each article

Post by Renegade_Mtl » Wed Oct 06, 2010 11:36 pm

So what you are saying is that I could use what was stated above tand apply it to the default_item.php file ?

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11614
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: How to control the article separator for each article

Post by ooffick » Thu Oct 07, 2010 8:42 am

Please note that there are multiple default_item.php files, so please make sure you are changing the one in the frontpage view.

Furthermore, depending on what you are trying to do, you can remove the article separator in the template overwrite, or change it to something else.

So e.g. you could remove the following:

Code: Select all

<span class="article_separator">&nbsp;</span>
To remove the article separator from the frontpage.

Or you could change it to the following:

Code: Select all

<span class="article_separator separator<?php echo $this->escape($this->item->params->get( 'pageclass_sfx' )); ?>">&nbsp;</span>
Which would allow you to use the Page Class Suffix (in the menu item) to change the article separator to whatever you want to.

You could also change it to the following:

Code: Select all

<span class="article_separator separator<?php echo $this->escape($this->item->id); ?>">&nbsp;</span>
If you want to style the separator for each Article in a different way.

There are other solutions as well, and you can style it all in any way you want to.

Olaf
Olaf Offick - Global Moderator
learnskills.org

JoOneShot
Joomla! Apprentice
Joomla! Apprentice
Posts: 15
Joined: Sun Dec 12, 2010 3:09 pm

Re: How to control the article separator for each article

Post by JoOneShot » Sat Dec 18, 2010 6:47 pm

is posibile to create parameters like this for module? For example in my left colum i want to don't show separator!

ISOIT
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Jan 19, 2011 11:59 am

Re: How to control the article separator for each article

Post by ISOIT » Wed Jan 19, 2011 12:06 pm

I also had this problem and according to the original post, you had to do a template override. I don't think this is nescecary.

So here's what I did.

Step 1 and 2 of the original post is fine. You add the parameter as an article param, and also as global.

As step 3 all you do is modify the file "default.php" in the "components/com_content/views/article/tmpl" library.

Her you locate

<span class="article_separator">&nbsp;</span>


and replace it with

<?php if ($this->params->get('show_article_separator')) :
echo '<span class="article_separator">&nbsp;</span>';
endif; ?>

, and you should be up and running.
Please note, that you have to delete the "item" in the if-condition for it to work, compared to the original post.


Locked

Return to “Core Hacks and Patches”