create dynamic template for joomla 1.5 - joomla

there are tutorials on the web about gow to create index.html, css file and template.xml that contain placeholders. ok, i got it, it's simple. but i need a template that has some different views. for example:
-all pages have a topmenu, header, left sidebar, mainarea and a footer but:
-first page has no header .topmenu after which sidebar, mainarea and footer comes.
-second page has sidebar moved from left to right
-third page has four blocks (blocks for special offers) instead of mainarea.
as far as i can see, i need to create three standalone templates with unique set of placeholders for each template. because i can't see the way to change laarge mainarea placeholder with four placeholders for offers blocks on some pages. dynamically.
is there if-statements in joomla templates to simply determine a document id to view four placeholders instead of mainarea. or to not show header on the main page (f.e. doc. id="mainpage")
but i want it to be selectable like:
-this page has first case of that template (index_1.php)
-and that page has a second case of the same template (index_2.php)
like a selectbox.
is that possible?

I will make this an answer as opposed to a comment since I believe it will do what you are looking for.
Once your articles are setup and your links to them are established (the site has the info on it you're looking for), you can create the modules containing the data that you want shown from time to time.
Go to the module manager - on the right you should see 'module assignment' or something along the lines of 'display this module on the following pages'; you can then pick which pages you want the module to show on. You can specify all pages, none, specific pages, however you want.
This will enable you to show them only where needed however you like.
You can ALSO do this programatically inside the module (if you do custom HTML and use an extension like Sourcerer to add PHP to the module) with PHP should you want a little more flexibility, but just choosing the pages to show on should work for what you're doing.

Related

How to include hooks in CMS pages?

I've created a custom hook, so that I can include my custom module in any .tpl file by a single line: {hook h='calcSubstrate'}.
However, I can't use it in CMS page, at least not by using the admin panel - including smarty code in a CMS page won't render, the code would appear just as it is, as a text: {hook h='calcSubstrate'}.
Alternatively, if that would be easier/faster - how can I choose on which pages my module would appear?
The editor for CMS page won't recognize any Smarty code. To include hooks in chosen articles/pages, I can think of two options:
Include the hook in the template (cms.tpl), and check for the id of the current page to conditionally display the module. The list of the page ids can be made as the module's configuration.
Build a module to add functionality similar to Wordpress's shortcode to the CMS content. I do this with module instead of overriding the CmsController class, hence I have to display the content with {$cms->content|module}. You can look at the simplified code here for inspiration: https://gist.github.com/tungd/cef0ca1ac1063c1ee90b. Of course you can make it more generic like Wordpress, by having only one Smarty modifier do_shortcode that does everything (just like Wordpress's do_shortcode function).
Last time I did this it was because my client want to put slideshows in some CMS pages, and I chose the second approach because it gives a lot of flexibility about when the module is displayed and where it is displayed between the content. For something else, for example Contact Form, or Map, this would be overkill and the first approach is better.

PyroCMS: How to include one page inside another

I have a site with an "About us" page which is divided into multiple sections.
About Us
+Overview
+The Company
+Our services
+Future plans
(etc)
I want to have a floated block on the right hand side of each of these pages which contains links to every other page.
Ideally, what I would like is to create a page titled AboutUsSidebar, and then be able to include this page in all of the about sections through some kind of tag, ie..
{include('Sidebar')}
Is there anything like this in PyroCMS? Or perhaps a better way to do it?
You should use view partials.
Create your sidebar with it's HTML and save it into addons/shared_addons/themes/yourtheme/views/partials/sidebar.html and then you can include it in your layouts as so:
{{ theme:partial name="sidebar" }}
It looks like page types are the way to go, I didn't see the page types button at the top of the page before.
In the end what I was able to achieve the desired result by using a page type.
I have a page type called "About" which contains the sidebar html, then I use pages on top of that page type for each of the sections.
Worked very nicely.

Joomla - How can I opt one from various modules to display in a position

I am willing to create a logic in which If I can fetch only desirable module in a particular position.
As we know that Joomla displays the module on basis of positions given to modules created, hence there could be several modules for a single position.
Now what If I only want a single module from those modules who has the position, say "positon-1".
Thanks
Each module can be told to be shown only on specific pages. Look in the module settings at the "Menu Assignment" part. There you can set it to show on
all pages
No pages
Only on the pages selected
On all pages except those selected
So you can set a module to show on the homepage in position-1, but on all other pages there is a different module shown on the same position.
Don't position names like position-1, although the example templates shipped with Joomla! do so. Use semantic names for the module positions. Then, within your template, you define, where these positions live.
Now what If I only want a single module from those modules who has ... [a certain] position
That will never happen then. You're going to have a position called search where the serach field is located, and maybe another one called navigation, where you publish your navigational menus. You get a lot more positions, but also much more flexibility. So if you have a module that needs its own position as in your question, let's have it that.

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.

Custom section/category viewing in Joomla

I have written some modules to have it look nicely. What I need now is to re-order Joomla's standard viewing of the content. I have looked into com_content, and my first idea was to write my own component for it. But now I realized it would be about 90% a copy of com_content.
The problem is: When you open a link to a section, com_content views a list of the categories. But I want a list of the articles in category News of each viewed, and a link to every article in category Infos on the menu to the left. And of course, view each on click.
Is there a way to achieve that without writing an own component? Or would it be advisable to customise com_content to my needs? I want this done with a minimum of fuss and complexity.
You can override components view-templates in your theme.
In your case, for articles: Articles are part of the content component. components/com_content/views/article/tmpl/default.php is the default view of an article.
To override it copy the file to templates\<yourtheme>\html\com_content\article/default.php.
As an example, see the default theme ja_purity or beez, which also override it.
That way, you will only change the layout and only for your theme. The component will stay in tact and updates will not be as complicated as otherwise.
The visible components on your website are called modules. See the modules section in the admin section. The category-view is one of the default modules. There is also a module to display a list of categories (AFAIK). That is what you want, right? The modules listed in the module section are not all available ones, but all that are created. You can create a new one and set its type to the category-list for example, and define in what block of the theme it should display.
If you want to do your own Module, do so. Code it, then add it in your admin section and you’re done.

Resources