How should I go about writing a Joomla! template? - templates

I am using Joomla! CMS to develop a website. In the not-so-distant past I customized a template to schlep up a website. It was fun and interesting to tear apart the code to de-joomla!-fy the template. So interesting that in fact, I am flirting with the idea of making my own template from scratch.
So, if I am to pursue this, where do I start? Do you know of any really good reference material, or should I just play with the code all day until things work out? I prefer to do tons of reading (for the concepts) before I go at it.

Create a HTML page with the layout you want, inclusive of stylesheets and Javascript
(1.5/2.5 is Mootools based)
(Joomla 3.x is jQuery based)
Adding Javascript
Keep the template initially very basic.
Save this page as index.php page.
The default directory layout is:
css
html
com_<componentname>/ mod_<modulename> (used to override the base templates of Components and Modules)
images
js
templateDetails.xml
index.php
favicon.ico
Change/Add the different Joomla constructs
Also updating the related templateDetails.xml with positions and file locations etc.
See a current template for an example of the layout.
Ex.
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
?>
Header section:
<jdoc:include type="head" />
Your different Modules:
<?php if($this->countModules('search')) : ?>
<jdoc:include type="modules" name="search" />
<?php endif; ?>
<jdoc:include type="module" name="breadcrumbs" />
Your Main Content tag is:
<jdoc:include type="component" />
To allow your template the ability to display debug information add:
<jdoc:include type="modules" name="debug" />
For more advanced additions to a template have a look at the default templates (ja_purity, Beez).
To override component and module layouts copy the layout files of the component or module into a similarly named directory below the html directory of your template and change it.
Edit...
Extra utilities.
To highlight the used module names in a browser add tp=1 to the end of your URL ex. yourdomain.com?tp=1
To View an inactive but installed Template add template=template_name. ex. yourdomain.com?template=Beez
These two can be combined, like this. yourdomain.com?template=Beez&tp=1
For more information look at:
Joomla Template Tutorial Part 1 - Joomla Template Concepts
How to Create Your First Joomla Template
Joomla! Docs: Template Development
Google Joomla templates

The time-honored method of learning how to do code/templates/anything is to "steal" from someone who already knows how to do it and then modify that until:
you're happy with the outcome; and/or
you've learned enough to be able to go it alone.
I suggest that would be the quickest route to success. Theory is fine but you'll learn faster by doing, and making mistakes.

Related

How can I add CSS style into backend my own joomla template?

How can I add CSS style into backend of my own template in Joomla? I'm trying to develop my own template for Joomla. Is there a solution to add CSS style to backend of template?
Regards Adrian
Yes, you can make a new template for backend too
If you are experienced web designer you can use the Admin Custom CSS (thekrotek.com) plugin – which allows you to redesign the Joomla back-end and build an individual and unique style with your custom CSS. Remember to enable the plugin and create a custom.css file in the administrator/templates/your_template/css/ folder.
I have found the following solution that works, even though it is certainly not technically the prettiest.
Add to templateDetails.xml:
<field
name="EigenesCSS"
type="textarea"
default=""
label="Eigens CSS"
description="Fügen Sie hier Ihr persönlicher CSS Code ein."
rows="10"
cols="5"
filter="raw"
/>
After that, add the following code in the head area of the index.php file after the regular links to the CSS files ($doc->addStyleSheet):
if (!empty($this->params->get('EigenesCSS'))) {
echo '<style>' . $this->params->get('EigenesCSS') . '</style>';
}
It is important that the code is loaded after the other CSS files, because this is the only way to overwrite the standard CSS definitions.

Magento - left.ptml not showing on all product list pages

left.phtml the file that displays the left navigation on a magento page is only showing on one list view page and not the others does anyone have a solution to get that file to show in all list views
If you are tasking left.phtml,
Then According magento structure left.phtml are only show for Non-Anchor category in it left side of category.
And layer navigation are only showing for Anchor category.for anchor left.phtml is not showing.
For non-Anchor categories
see catalog.xml code
<catalog_category_default translate="label">
<label>Catalog Category (Non-Anchor)</label>
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left.phtml"/>
</reference>
Also for
Anchor categories
see at catalog.xml
<catalog_category_layered translate="label">
<label>Catalog Category (Anchor)</label>
<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
</reference>
Hope ,you will understand.
Check the layout in folder theme/package (it can be in default/default, when your theme is in another folder)
Check if layout is plugged (use in your layout.xml something like <remove name="header">). If header will be removed - you use correct layout
Check the handle and reference name, where you are adding block. For example: you are adding layered navigation block. On one page it placed in handle <catalog_category_layered>, but your page there no this handle. Try to add to <catalog_category_default> or even in <default>.
Open your template and check if the block was added there. Look for
<?php $this->getChildHtml('blockName'); ?>
Try to change your block name (maybe on this page already exist block with the same name)
(this option can be useless for you) Please check the block output in system / configuration / advanced
Maybe there is a conflict between two navigation modules (for example module A and module B). The module A can use it for rewrite. But the module B will use it only for investigation and use on this page it's own calls. In that case the module A will not work (to resolve this issue you need to change rewrite. class A should rewrite class B)
If you are trying to add navigation to CMS page - try to google this topic (how to add navigation to CMS page). There are many examples and I don't want to duplicate them.

Dynamically inserting properties into JSF2/Primefaces templates?

I am creating a simple web application to try out JSF2 with PrimeFaces, so far really impressed by how much it can do out of the box. Going through various tutorials and articles I have a question about properties in templates and whether it is possible to insert these.
I know I can insert chunks of HTML content in templates, for example:
<title>
<ui:insert name="title">Default Title</ui:insert>
</title>
But in some cases it would be useful to insert at property level. The specific one I thought of was TabMenu, where if you were using a TabMenu for navigation (and you want the same TabMenu on every page so it makes sense to use a template), you would want to set the 'activeIndex' differently depending on which page you were looking at. This however does not seem to work in a template file:
<p:tabMenu <ui:insert name="activeIndex">activeIndex="0"</ui:insert>>
<p:menuitem value="Overview" outcome="main" icon="ui-icon-star"/>
<p:menuitem value="Demos" outcome="demos" icon="ui-icon-search" />
<p:menuitem value="Documentation" outcome="docs" icon="ui-icon-document"/>
</p:tabMenu>
Hope that makes sense. Is there a way to do this, or is this design just completely wrong and there is a much better way of doing it?
Pass it as <ui:param>.
E.g. in template client:
<ui:composition template="/WEB-INF/templates/some.xhtml">
<ui:param name="activeIndex" value="0" />
...
</ui:composition>
and in master template:
<p:tabMenu activeIndex="#{activeIndex}">

Magento - catalog.xml not using correct template

Noob developing a Magento theme and I can't seem to figure out why Magento is not using the path I specify in the setTemplate action on catalog.xml.
I've got my own theme in /app/design/frontend/default/mycustomtheme and I've been patching files over from the base and making changes.
I've copied over /app/design/frontend/base/default/layout/catalog.xml to my custom theme at /app/design/frontend/default/mycustomtheme/layout/catalog.xml. I've set the template to be a specific phtml file...
<catalog_product_view translate="label">
<label>Catalog Product View (Any)</label>
<!-- Mage_Catalog -->
<reference name="root">
<action method="setTemplate"><template>page/2column.phtml</template></action>
</reference>
Yet it's not working. Can someone spot what the problem might be? I've got all cache disabled and other changes I make I can see immediately, just not this one.
edit: I should note, if I change something else in the catalog_product_view xml node I see those changes are reflected. For instance if I remove <action method="addJs"><script>varien/product.js</script></action> then I see the reference is removed in the rendered html file.
edit2: Adding images to address questions ...
did you setup-up / configured the theme from your store backend?
Yes, and it's actually loading the correct header and footer, and it's properly styled.
Are you sure you have such template under /app/design/frontend/default/mycustomtheme/template/page/ directory?
Yes, I can confirm the file is there
OMG. The (one and only) product I was testing on had a specific layout set under the "Design" section. So I guess that was overriding anything I had set in catalog.xml
I'd like to have the 3 hours of my life back.

CodeIgniter: tips for using templates

Just started using Codeigniter (yesterday) and am wondering what templating features people are using?
Is it possible to create a view and just load it whenerever necessary?
Thanks,
Jonesy
The idea of templating is to create a shared layout with a common header. footer etc and then just have a "body" that changes per-page.
At the most basic level you can just include header and footer inside each of your views like this:
load->view('header'); ?>
This is my page.
load->view('footer'); ?>
That can be fine but start building an application of any real size and you'll find problems.
There are million ways of doing templating, but the way I have used for years is this Template library. It's seen me through 20-30 projects varying projects and is used by many so you know it's tried and tested.
Is it possible to create a view and just load it whenerever necessary?
Yes. This is the typical behavior of the MVC structure, not just in CI. Your views are presentation layers that should be mostly devoid of logic/processing.
Another way to do this is the following.
In your controller, load your template like so
$template_data = array('contains', 'data', 'for', 'template',
'while', 'the', 'specific' => array('may', 'contain',
'data', 'for', 'the', 'view_file'));
$this->load->view('template/needed.php');
In your template, you now have the $template_data array to populate it [if need be!]. You may now load the specific view like so
<div id="yield">
<?php echo $this->view('specific/viewer.php', $template_data['specific']); ?>
</div>
Note:
The template/needed.php should be in the application/views folder.
The specific/viewer.php file should also be in your views directory (i.e. the path to this file should be something like WEB_ROOT/application/views/specific/viewer.php)
The beauty of this is that any view file could be used as a template if need be.