Joomla: Override Category Blog output multiple times? - joomla

Yes. I want to override output of Category Blog component to 2 different display styles.
For first style, i copied and edited blog_item.php & blog.php in [mytemplate]/html folder. Then i choose template style from dropdown in backend of my category blog. That's worked. The display of category blog change as i expected.
But if i want to create another style and use in another category blog. How could i do ? And how to i named my files ( I tried blog_1.php, blog_item_1.php ) but only see my first style display in backend.
I'm using joomla 2.5.
Please help me. Thank you very much !
=================================================================================
[UPDATED]
I solved this issue. Here my solution:
Clone my template to [my_template_2]
Go to [my_template_2]/html/com_content/category then edit blog.php, blog_item.php as my needs.
Go to backend, at my category blog menuitem, i assigned [my_template_2] as its template style.
Then it worked. Both my category blog have its own style.
This maybe not very good solution because i have to use multiple templates, but at this time it's quite enough for me.
Thank you, stackoverflowers.
=================================================================================
[UPDATED 2]
Now, with multiple template styles, I could create unlimited styles for my category blog component within just only one template. That's very much better.

As you may know, joomla doesn't let developers make different styles for its components.
I think you have to list all menus which are made by "category blog component" in template managing page and let users set each menu style at there.**
and at blog.php, check template setting and then load customized style...
** you have to develop a custom field element which list all "category blog component" menus.
* you can use this code to accessing template parameters in component's template :
$app =& JFactory::getApplication();
$template = $app->getTemplate(true);
$paramsTemplate = $template->params;
$style = $paramsTemplate->get('style');

You don't need to use multiple styles. What you need is to use alternate layouts and alternative menu layouts.
For alternative menu layouts in the html/componentname/category folder of your template make a new style with a unique set of names similar to the way blog already provides an alternative to category list in the article category layout folder. Also make a new xml file for each layout that you make, with a matching name.
When you create your menu item you will now get these alternatives along with your other normal choices. Just select the one you want.

Based on the learnings above here is my code for the /templates/mytheme/com_content/category/blog.php
And then in the Global Configuration > Article Manager Options > Category choose Blog as the override/ layout.
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');
$pageclass_sfx = trim($this->pageclass_sfx);
// so pick it on the page class in menu item
if (isset($pageclass_sfx) && $pageclass_sfx != '') {
echo $this->loadTemplate($pageclass_sfx);
} else {
echo $this->loadTemplate('default');
}
I can add multiple elseif if something else is needed, or it will look for 'blog_' . $this->pageclass_sfx . 'php'. It is always beginning blog_ as thats coded into the com_content. The old blog i moved to blog_default.php and blog_default_item.php

Related

Restricting Slideshow CK to certain pages within Joomla

I am trying to show Slideshow CK only on the homepage of my Joomla based site. I have gone into the 'assignment' section of the module and restricted it to 'Home' menu item and said 'no' to include on child items. This works fine. I only see the slideshow on my homepage. However, I have created a link to an article on one of my other menus. When that article is displayed, it shows the slideshow. I want to suppress it when it jumps to that link. I have been playing with various options but without much joy. I would appreciate it if somebody can clarify the control mechanism for selectively displaying the slideshow.
I have found a method of overcoming the problem but someone may suggest a better approach. I specifically went and excluded certain selected articles in the assignments. I had tried to exclude a 'hidden' category but that did not work for me. The downside of my approach is that every time I introduce a new article I have to exclude it.
If I understand correctly you are creating articles without menu items. Without a menu item you won't be able to control the module assignment so easily.
If you're comfortable editing your template an lternative approach would be to amend the template and load the module.
Locate the index.php file of your template. You should be able to do this via the template manager.
Create a custom module position e.g. slideshow-ck and assign the slideshow module only to the homepage.
Then in the template you would need to add some PHP as follows:
<?php
$menu = $app->getMenu();
$active = $menu->getActive();
if ($menu->getActive() == $menu->getDefault('en-GB')) && $this->countModules('slideshow-ck') ?>
<jdoc:include type="modules" name="slideshow-ck" style="html5" />
<?php endif; ?>
Basically what that does is only load the module position if it's assigned to the menu item AND the user is currently viewing the homepage.
https://docs.joomla.org/How_to_determine_if_the_user_is_viewing_the_front_page

Adding Joomla Article Order number inside an article

I am trying to create a Joomla site that would be showing the article order numbers (not Article ID) inside each article. that way I can handle it like a book.
Each page will show the article order number at the corner - like a page.
That way I will be able to have the site modeled by categories and pages will show with their page number (Article Order number) at the corner.
I want to give the user the ability to watch the pages like they are reading books by categories.
I would be happy to know - how can I add the article order number (for each category) inside the article itself.
I am sure that there is a PHP code that can do that.
Thanks so much for your help and assist.
Arye
You'll need to override the default article layout in your template.
If your template doesn't already have an article layout, you can copy the default layout from components/com_content/views/article/tmpl/default.php inside your template override templates\[YOURTEMPLATE]\html\com_content\article\default.php (replacing [YOURTEMPLATE] by your actual template name.
You can then display ordering where you require it within your template by using
<?php echo $this->item->ordering; ?>
You'll most likely want to either check for a certain condition (the article's category, perhaps) to determine whether you want to display the ordering.
Another option is to create an alternative layout instead of overriding the default one. You can rename default.php in your template to, let's say bookpage.php. You will then be able to pick the new layout as an alternative layout in your articles' options.
you can get article id by using
Request::getVar('id');
for more you can check the link
Joomla plugin : how to get article title and article id
for jquery you can do like this. you can create a function and call on every page load it will sort all your content accordingly. you can assign other attributes also in foreach loop.
<div id="allArticles">
<article id="3">Article 3</article>
<article id="1">Article 1</article>
<article id="2">Article 2</article>
</div>
$("#allArticles article").sort(function (a, b) {
return parseInt(a.id) > parseInt(b.id);
}).each(function(){
var elem = $(this);
elem.remove();
$(elem).appendTo("#allArticles");
});
more you can see the working example here http://jsfiddle.net/THMu3/

Joomla module position showing

I want to load a Joomla module in a specific position in a category, but I don't want to show it in an article page on that category.
I am making the assumption that you mean you are using the "Category Blog" or "Category List" feature, and wish a module to appear in the category listings view, but not the article view.
If this is for a single page then you can just set up a menu item for the problematic article using the "single article" menu item type. The listings will then redirect to that page instead of dynamically generating them. You can assign modules to individual menu items as normal.
If this is for every article, then one way to do this is to edit the module.
It will have a file called something like mod_yourmodule/mod_yourmodule.php
This will contain code like this
require JModuleHelper::getLayoutPath('mod_yourmodule',$params->get('layout', 'default'));
Change this to
$input = JFactory::getApplication()->input;
$view = $input->get('view');
if ($view != "article") {
require JModuleHelper::getLayoutPath('mod_yourmodule',$params->get('layout', 'default'));
}
This will then not render if you are on an article page. If this file is a core file, you are probably better adding similar code on your template, but using it to add a style sheet which hides the module. You should never change core files.

Joomla 3 - How to get the Global Article Manager options

I am looking to modify the article component ( I do not want it to have the same article options as my main menu, but rather use the global article settings and not have to change it for each individual article, see: Joomla 3 Article Options - How to get article view different from category blog view)
To do this I need to get the parameter values set in the global article manager options (System->Global Configuration->Articles). For example the "Show Author" parameter. I have tried googling this to no avail. I have looked at the docs for JApplication, JRegistry and more and cannot see anything that would point me in the right direction.
I could probably do a SQL query to get the values, but it feels as if Joomla should have this functionality already built in.
Thanks
Roelf
You should be able to do this like you would for any component's parameters:
$app = JFactory::getApplication('site');
$componentParams = $app->getParams('com_content');
$param = $componentParams->get('paramName', defaultValue);
More here: How to get component parameters?
Beyond setting parameters on the article itself, you can also override the parameters on a menu item basis. A common practice is to set the global parameters to be what you generally want for pages. Then create a menu item for say your blog category and override the article settings for the blog menu item to create the different feel of the blog.
As long as you are using menu items and core content layouts, you really shouldn't need the code above.
There are three different places where you can select the individual parameters.
In Menu Magager you can choose whether to be Global, choices in each article or the setting in the specific menu that determines each parameter
Global configuration, see Content / Article Manager - select Options.

Joomla 1.5 / Modification of YooTheme "ZOO" Component

I'll start out by mentioning that there is a developer forum for Zoo and I have used it already. My purpose posting here is that I typically get a thorough answer within minutes or hours at SO, whereas the responses on dev forums can be slow or non-existent due to the smaller population base.
My question regards Yootheme's ZOO 2.3.2. By default, a product "Frontpage" appears to have a "Categories" box rendered on top of the items. If one turns off all the available options in Frontpage/Template configuration (hide Titles, Count, Descriptions, etc.), an empty box still remains on top of the items.
I've been able to manually remove the box in its entirety by addressing the following file:
media/zoo/applications/product/templates/default/frontpage.php, and commenting out lines 84-92:
<!-- <?php
// render categories
if ($this->category->childrenHaveItems()) {
$categoriestitle = $this->application->getParams()->get('content.categories_title');
echo $this->partial('categories', compact('categoriestitle'));
}
?> -->
Seems like there should be a more eloquent way of doing this on the admin backend, but I couldn't find one. Am I missing something or is my solution the best one?
ZOO is designed to easily be able to modify the built in templates to suit your needs. ZOO templates are meant to be overridden much like Joomla uses template overrides. Rather than editing the default template, you simply create a new template that does what you want it to. The default template should not be changed.
Here is the documentation on ZOO templates - http://www.yootheme.com/docs/home/item/create-a-new-template
Rather than edit the file you mention above, you make a new template here -
media/zoo/applications/product/templates/YOUR-TEMPLATE-NAME/frontpage.php
Then do all the changing you want without messing up the default.
There is an easier way: First, you must identify what calls the item called "frontpage". In PURE yootheme at least it is called from "home" in the "mainmenu". So click "home" buton of the mainmenu, then over the right menu "Parameters(Basic)" you just chose "-select aplication-" instead "frontpage" and that's it.The Frontpage and its "box" are now gone. At least it works for me.

Resources