How do I set the theme layout from within a module in PyroCMS? - pyrocms

I'm doing
$this->template
->set_breadcrumb(lang('stuff'), 'stuff')
->set_breadcrumb($col->title)
->set_layout('questions')
->set('title', $col->title)
->build('view', $this->data);
But my questions layout file in my my_theme folder.
How do I specify the layout directory?

Your question changed while I was answering it so now I am confused. This is correct, it previously wasn't.
PyroCMS Template Library docs
The location is addons/<default or shared_addons>/themes/<theme>/views/layouts/ and the questions.html layout should be set in there, right next to its buddy default.html.
You can of course skip all of this and just make a layout that has the same name as the module. So, remove the set_layout() method entirely and you've already completed your task.

Related

How do I apply nonintrusive design changes to Magento 1.X

I am having a little trouble here with a Magento installation here, which I "inherited" from a company who did some pretty heavy customizations to the theme.
I tried to rationalize most of the changes and was pretty successful with it. The problem is now, that I have some template files which have only one line of change.
In this specific case for example it would be a <button> that is now an <a> link. This is pretty much only one line in a 300 line template file.
Similar problems occurred with layout files of extensions. They have ONE dirty line in there, which for example resets the whole layout.
I then need to overwrite the complete layout XML file in the design, just to make a little change in one line, because those layout files are either overwritten or not. There is not merging process involved.
I took a look into the designer's documentation of Magento, but could not find anything useful.
I know that I could do some specific layout changes in the "local.xml" in my design, but those are more or less "contextless", which is not that great if those changes do belong to a certain extension.
Do you know a way to apply little template changes like mentioned in the first half or partially layout file overrides?
My main goal is to keep the files automatically updatable, which pretty much means: Download the module, replace files, done.
No manual updates to any overwritten files.
Use the "inherited" template as default template in a new package and add a child template with your changes. Example:
app/design/frontend/[package_name]/default - here will be the "inherited" old template
app/design/frontend/[package_name]/[your_child_template] - here will be your new child template
skin/design/frontend/[package_name]/default - here will be the "inherited" old template
skin/design/frontend/[package_name]/[your_child_template] - here will be your new child template
Partially layout file overwrides can be done for all pages or extensions in one local.xml file. Example:
app/design/frontend/[package_name]/[your_child_template]/layout/local.xml
If you want to add changes for a certain extension just add the extension xml file in your template folder. It will be the last one rendered and will wthe original. Example for the checkout cart page:
app/design/frontend/[package_name]/[your_child_template]/template/checkout/cart.phtml
For a small change inside a phtml file like your button example you will have to overwrite the whole phtml file. There is no way in Magneto to overwrite just a part of a phtml file.

Locating Layout/Template - Magento

I need a little bit of guidance. im new to Magento and getting lost with the Templates/Layout structure when it comes to design of a custom theme.
From my understanding there are two types of blocks:
Structure Blocks and Content blocks.
Structure blocks define the structure of the site and Content blocks call .phtml template files to populate the structure blocks with content (please correct me if im wrong).
I have an area that i would like to update, when i turn on the debugging in magento i am advised that the area that i wish to update is located at:
frontend\meigeetheme\default\template\meigee/meigeewidgets/grid_2.phtml
Essentially what i would like to do is get a Categories menu in this area. I expected to find the structural block in a folder within the layout directory called meigee, but i am unable to find any .xml document that represents the defining structure that this template is called in to.
Any idea how i go about it?
All advice and criticisms welcome. Thanks in advance.
Oki doki, so doing my research i found a very useful peace of code. I would like to give credit to user: djdy.
If you include within a .phtml file:
$this->getLayout()->getBlock('root')->getTemplate();
obviously:
<?php echo $this->getLayout()->getBlock('root')->getTemplate(); ?>
it will do a nice little echo of the layout being used.
Proved quite helpful in resolving my task. It seemed that grid_2.phtml was being loaded within:
frontend\meigeetheme\default\template\page\1column.phtml
then according i was able to add the block i needed in page.xml and call using getChildHtml. Hope this helps!

How to locate a block that is used by Magento, but isn't displayed in the admin panel?

I've inherited a Magento shop site, and the previous developer has gone AWOL. So I'm left with a sheet of paper essentially telling me how to do basic things such as changing the banner on the home page. That's pretty much it.
The person who owns the page now wants to change an advert that's held on the right hand side on the product pages. I've searched in the Admin panel under CMS and drawn a blank. I've navigated through the template files and I've found the 3 column HTML file that I thought contains the actual advert.
It doesn't. Instead, it has the following code:
<div class="col-right sidebar"><?php echo $this->getChildHtml('right') ?></div>
Where can I find the Child HTML? I've searched all of the folders for the file that I'm assuming is called "Right". But I can't seem to find it.
Anyone know where something like this could or would be held?
That is the absolute most root function, anything that is placed in the child "right" will be displayed here and is most certainly not where you want to be doing your editing.
There are literally a hundred different ways content could be posted here and what I would recommend to start with is first determining if it is a static block or a template file.
Go to System -> Configuration -> Developer.
Change "Current Configuration Scope:" to the store you are currently troubleshooting.
Find your IP and place it in "Allowed IPs (comma separated)", this way the next steps will only be visible to you.
Under the "Debug" section you should now see "Template Path Hints" enable this and reload the page.
If that block now has something like: "app/design/base/default/catalog/product/view.phtml" you know it is in a phtml file and you can go there. If it doesn't:
It could be a banner, go to CMS -> Banners and check there.
It could be a static block, go to CMS -> Static Blocks
It could be...any number of things.
You stated that it is on the product page, next step is check catalog.xml in your layout folders. Search for and see if anything inside of there makes sense about what it could be. If the previous developer was any kind of proficient it won't be in catalog.xml but in local.xml OR a custom module's .xml file in the layout directory of the custom theme.
Try doing a search on the code base for the content inside of the block and see if anything pops up. If nothing, use phpmyadmin to search the database for some of the content.
Hope this helps a little.
Search for:
<reference name="right">

How to call a custom php file on magento product page

if getChildHtml('product_type_data') ?> maps directly to catalog/product/view/type/simple.phtml by default, how do I map to my own file? If I wanted to create a file that would produce a small image to place on the product page, right under "availability" how would I tell magento to map to where I have put the file? From what I understand getChildHtml('product_type_data') ?> defaults to the file path: catalog/product/view/type/simple.phtml so how can I customize the magento defaults and tell it to map to my custom files i've created?
Could I do something like getChildHtml('etc/etc/my-file.phtml') ?>
Essentially, what I am trying to do is add a small image under "availability" of my site (ex: http://climbhigh.com/climbing/climbing-ropes/petzl-dragonfly-rope-8-2mm.html) that says free shipping. Just trying to find the best way to do it.
I hope I have explained this well enough, if not, please let me know and I will try to explain more. Any help or guidance would be awesome. Thanks.
The code getChildHtml('product_type_data') doesn't always map directly to the template file catalog/product/view/type/simple.phtml. It only maps to that file if the layout handle PRODUCT_TYPE_simple is loaded, i.e. if the current product is a simple product. In order to change the template to be a different one you need to update the template attribute in the layout. At it's most simple this can be achieved by editing app/design/frontend/base/layout/catalog.xml and changing the template attribute.
<block type="catalog/product_view_type_simple" name="product.info.simple" as="product_type_data" template="your/new/path.phtml">
Of course editing core files is a bad idea, so you should make a quick search for how to correctly add layout updates via either local.xml or customer layout update files.
I ended up figuring out what I needed to do. I simply wanted to add a small image to my product detail page that highlight a free shipping option. All I had to do was create a static block in the admin panel of magento and go into catalog>product>view.phtml file and insert:
getLayout()->createBlock('cms/block')->setBlockId('your_block_id')->toHtml(); ?>
it worked like a charm!
thanks for the help Crags

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