Using modules in Joomla K2 Sub-templates - templates

I have a quick question connected with my little knowledge of Joomla\K2. I'm using subtemplates to create different layouts for different pages. When I declare module position on sub template:
<jdoc:include type="modules" name="position-7" />
Nothing happens. I've tried the same code for main template file and it worked, but seems like it's not parsed for sub-templates. Am I right? How can I include modules into sub-templates then?
thanks in advance,
Michael

jdoc tag only works in joomla core template. If you want to load modules of specific position in your k2 subtemplate write the following code at your desired location in that subtemplate.
$module = JModuleHelper::getModules('xxxx');
// xxxx is any virtual position, no need to create it anywhere.
echo JModuleHelper::renderModule($module[0]);
replace xxxx with your desired position name.

Related

Customizing Joomla template

Good day!
Could you help me to figure out how to customize joomla 2.5 template. The problem is that main(index page) shouldn't contain header block, but other pages should. Is there any solution for this (maybe somewhere in administration panel located this option). Sorry for my bad english and pure knowledge of joomla.
It could help if you could show me your site,
but one easy option would be to use following to test for front page in your template:
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
echo 'This is the front page';
}
?>
another option would be to prevent all header modules from showing on the front page (if your header is made of modules)
You could use two different templates and assign one of them to your front page and make the second one default, so it will be assigned to the rest of your pages. However, you wouldn't normally do that if the only thing that's different is the presence of the header and everything else (like layout, colors, shapes, etc.) is the same.
In your case it makes more sense to implement your header as a module (use "Custom HTML" module type) and set it up to only display on the front page.
Good luck!
удачи!

Customizing Containable Content in Orchard CMS

I am currently trying to understand a bit more about how Orchard handles Lists of Custom Content Types and I have run into a bit of an issue.
I created a Content Type named Story, which has the following parts:
Body
Common
Containable
Route
I created a list that holds these items, and all I am attempting to do is style them in such a way:
Story Title
Story Description (Basically a truncated version of the body?)
However, I cannot seem to figure out how to do the following:
Get the Title to actually appear (Currently all that appears is the body and a more link)
Remove the "more" link (and change this to be the actual Title)
I have looked into changing the Placement.info, and have looked all over in an attempt to find where the "more" link is added in each of the items. Any help would be greatly appreciated.
I finally managed to figure it out - Thanks to the Designer Tools Module, which made it very simple to go look into what was going on behind the scenes during Page Generation.
Basically - all that was necessary to accomplish this was to make some minor changes to the Parts.Common.Body.Summary.cshtml file. (found via ../Core/Common/Views/)
Which initially resembles the following:
#{
[~.ContentItem] contentItem = Model.ContentPart.ContentItem;
string bodyHtml = Model.Html.ToString();
var body = new HtmlString(Html.Excerpt(bodyHtml, 200).ToString()
.Replace(Environment.NewLine,"</p>"+Environment.NewLine+"<p>"));
}
<p>#body #Html.ItemDisplayLink(T("more").ToString(), contentItem)</p>
however by making a few changes (by using the Designer Tools) I change it into the following:
#{
[~.ContentItem] contentItem = Model.ContentPart.ContentItem;
string bodyHtml = Model.Html.ToString();
string title = Model.ContentPart.ContentItem.RoutePart.Title;
string summary = Html.Excerpt(bodyHtml, 100) + "...";
}
<div class='story'>
<p>
#Html.ItemDisplayLink(title, contentItem)
</p>
<summary>
#summary
</summary>
</div>
Although it could easily be shortened a bit - It does make the styling quite a big easier to handle. Anyways - I hope this helps :)
Alternately you can use the placement.info file in your theme assign different fields to your Summary and Detail views. It's much simplier.
http://orchardproject.net/docs/Understanding-placement-info.ashx
But, I used the same method you did till I discovered the .info file as well. It works and gives you a good understanding of how the system works, but the placement.info file seems easier.
Also, you probably don't want to be editing the view files in Core. I think your meant to override views in your theme directory.

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.

How should I go about writing a Joomla! template?

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.

how to add a new modulo position on a joomla template?

i'm using a joomla template called decayed and it doesn't have the right position, only the left one and nothing more.
i would like to add a right and a button positions on that template. how can i do it?
cheers
Assuming you're using joomla 1.5, go into the template directory (/templates/someTemplateName/). I don't know anything about this theme, but if it follows the standard scheme for a joomla template, then modify these two files:
1) index.php
<jdoc:include type="modules" name="myModulePosition" />
Add that wherever you want your module to appear in the template (and substitute "myModulePosition" for what ever you want the module position to be named).
2) templateDetails.xml
Find the xml tag , should probably look something like this:
<positions>
<position>left</position>
</positions>
And add a new tag with your new position, such as:
<positions>
<position>left</position>
<position>myModulePosition</position>
</positions>
That way, your module position will show up in the list of available positions when you're adding/modifying modules.
scott solution may not work at all.
I simply do this by going to DB find module in #__modules table and add in the field "position" the name of desired position, It is hard way but it work's well