How do I display "News" on the Home page? (Magento) - magento

I need news articles to be displayed on the front page but the standard way, to put this code {{block type="profile/profile" name="profile" template="profile/news-front.phtml"}} in the editor on backend doesn't work, even though I have created file news-front.phtml in the template/profile. I really-really need help with this. The output in system.log is Not valid template file:frontend/base/default/template/profile/news-front.phtml

Is the block type really going to be profile/profile? If you are just hoping to output the file as PHP/HTML you may want to consider using core/template rather than profile/profile.

Related

Is it possible to change text directly in the code

I would like to know if there is a way to change text in the code instead of using the admin panel? I have Filezilla installed and can access my site/files from there.
If I use the inspect element in any browser, I can see an HTML structure, but as I have understood there is no HTML document in Magento, right? So where do I go if I want to make a change to a text element on my site and I don't want to use the admin panel?
Most of the text elements are handled by Magento's language translation system.
Quite often, you don't have to mess around hacking templates, just simply add a line to the translation CSV with the text string exactly as it appears, add a comma and then the new text string you want Magento to display.
For example, if you're working with US English, you can use the following file in your own custom template package as follows:
app/design/frontend/default/your_package/locale/en_US/translate.csv
Let's for example, change one of the window shade bar titles in the One Page Shopping Cart. Add a line to translate.csv as follows:
"Billing Information","Billing Address Information"
How this works, in the template the following line normally displays the title:
<?php echo $this->__('Billing Address') ?>
This code snippet $this->__('Billing Address') is a call to Magento's language translation system. It reads the translate.csv file finds Billing Address and changes it to Billing Address Information when it assembles the page html.
Lotta people out there have made changing text like this far harder than it has to be.
Hunting down the proper template, changing the text, finding the template got messed up, or trying to remember after the fact what was changed.
VS.
Changing a simple central file that contains all the text string translations... Often only by adding a new line to the file
Magento actually makes this very simple.
Thank you! So magento stores all text in .csv? or just the stuff that needs to be translated? I'm making a search for .csv via Filezilla but I only get two languages (the site is translated to multiple languages). Should I be looking somewhere else?

Markup tags in product descriptions

I'm trying to use markup tags to link to info pages within the "description" attribute of a product. However, it's not giving me a clean URL path when the description is printed to the page.
Trying:
Contact Us
does not give the expected url. I've confirmed i'm doing this outside of WYSIWYG mode too.
When the text is rendered is returned to the browser as this html:
Contact Us
A resulting click on the link then ends up as:
http://example.com/prod-category/my-product/%7B%7Bstore%20url=
From what I can tell the markup tags aren't designed to be used in this way. Is it possible to extend it so it could work? Otherwise I guess I need to include the actual URL in the description?
Thanks for suggestions.
You can´t use the double-curly syntax because the attributes value is not being processed by magento´s template filter, which does the magic. You can use them e.g. in CMS or email Templates out of the box.

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

Adding pager to custom collection block

Sorry for the redundancy of this question, but none of the example and solutions have worked for me. I have a custom module that extends Mage_Catalog_Block_Product_List. The only function in it is _getProductCollection which sets the product collection based on which attribute you want to filter on. It's pretty simple and there are no layout updates involved. I put the block on the page by putting the following into the Content section of a CMS page:
{{block type="vps_featured/list" name="vps_featured_list" attribute_name="best_sellers" template="catalog/product/sale_list.phtml"}}
Since it extends Mage_Catalog_Block_Product_List, I get all the bells and whistles for a product list page, including the toolbar. However, the pager isn't there. I've tried a number of different suggestions but none have helped.
I looked in Toolbar.php in the core code and found where it calls getPagerHtml. I put some debug statements in there and determined that it calls this function when putting my custom block on the page but $this->getChild('product_list_toolbar_pager') is not returning the block, presumably because it isn't there. I tried adding the block using a layout update XML file and adding the <frontend><layout><updates>... tags to my config, but this didn't seem to do anything.
I have Alan Storm's CommerceBug extension, so I pulled that up and exported the layout XML for the page. It doesn't contain any toolbar block at all, despite the fact that the toolbar is on the page and only the pager isn't working. If I do the same thing on a category landing page, it shows the toolbar block in the layout xml. So I've clearly missed something here, but I'm at a loss as to what. I hope someone can help :)
Brian
As it turns out, the solution found HERE works great! You have to add the block using the Layout Update XML rather than adding it in the content section. I still don't quite understand why, but it works.
There already was question about Getting pager to show on magento list

Resources