Magento content management; prevent a mess - magento

So, I started on a new project this week and of course I'm thinking about the problems I'm going to find during the whole development process. We are going to make a shop that has a pretty good design, pretty excited to work on this. However, the design uses a lot of content that can't be placed in the normal functions of magento. For example there is a catalog page that has a lot of content blocks with secondary information like unique selling points or a bit of story telling. This can and will be different for different categories. We are talking about a lot of small content blocks, not something you can cram into the category description field ;)
Until now I mostly used static blocks to make this content and show them on the pages, maybe even use xpath to extract the information I need from the blocks to prevent the end-user from destroying the design by using the WYSIWYG editor. However, I don't think this will be a good solution now because there will simply be to much static blocks to create and use without loosing the overview of everything, plus I doubt xpath is really good performance wise (something like getting a screw in with a hammer).
I was thinking about making a module or using a module that makes it possible to add attributes and use attribute sets in combination with static blocks. With that you can make your own fields and groups for certain pages and make it easy for the end-user to edit information on their webshop. However, making this myself (does sound like a lot of fun) will take to much time, and I can't really find a module that does something like this.
How do you guys solve these problems when creating a new webshop? Any tips?

I suppose you will be using your own theme with own template for the category page, here you will setup all the HTML that you don't want the admin to mess up with the WYSIWYG editor and let them change only certain parts of the page. For the admin to be able to edit these, you will need to add new attributes to the category entity. For example if the admin should add text for a certain box, add text type of attribute, if the admin wants to add HTML create WYSIWYG editor type of attribute and so on. Then in your template you will check if the category has any of these attributes and they have non-empty values then print them.
For example:
<?php if ($category->getCustomTextAttribute() != ''): ?>
<div id="your-div">
<?php echo $category->getCustomTextAttribute(); ?>
</div>
<?php endif; ?>
<?php if ($category->getPromotionHtml() != ''): ?>
<div id="promotion-div">
<?php echo $category->getPromotionHtml(); ?>
</div>
<?php endif; ?>
This goes the same for the product pages with the difference that for products you can create the attributes via the admin and then print them on the product page template, otherwise for Categories you need to write a module that does this, if you want me I can provide you with an example of module for creating Category attributes.

I ended up using a combination of zokibtmkd answer and adding fields to the default static blocks (a image upload function and a link field). The combination of these two solutions gave me enough to work with in the design without messing up the admin or the templates.

Related

Restricting Slideshow CK to certain pages within Joomla

I am trying to show Slideshow CK only on the homepage of my Joomla based site. I have gone into the 'assignment' section of the module and restricted it to 'Home' menu item and said 'no' to include on child items. This works fine. I only see the slideshow on my homepage. However, I have created a link to an article on one of my other menus. When that article is displayed, it shows the slideshow. I want to suppress it when it jumps to that link. I have been playing with various options but without much joy. I would appreciate it if somebody can clarify the control mechanism for selectively displaying the slideshow.
I have found a method of overcoming the problem but someone may suggest a better approach. I specifically went and excluded certain selected articles in the assignments. I had tried to exclude a 'hidden' category but that did not work for me. The downside of my approach is that every time I introduce a new article I have to exclude it.
If I understand correctly you are creating articles without menu items. Without a menu item you won't be able to control the module assignment so easily.
If you're comfortable editing your template an lternative approach would be to amend the template and load the module.
Locate the index.php file of your template. You should be able to do this via the template manager.
Create a custom module position e.g. slideshow-ck and assign the slideshow module only to the homepage.
Then in the template you would need to add some PHP as follows:
<?php
$menu = $app->getMenu();
$active = $menu->getActive();
if ($menu->getActive() == $menu->getDefault('en-GB')) && $this->countModules('slideshow-ck') ?>
<jdoc:include type="modules" name="slideshow-ck" style="html5" />
<?php endif; ?>
Basically what that does is only load the module position if it's assigned to the menu item AND the user is currently viewing the homepage.
https://docs.joomla.org/How_to_determine_if_the_user_is_viewing_the_front_page

Adding Joomla Article Order number inside an article

I am trying to create a Joomla site that would be showing the article order numbers (not Article ID) inside each article. that way I can handle it like a book.
Each page will show the article order number at the corner - like a page.
That way I will be able to have the site modeled by categories and pages will show with their page number (Article Order number) at the corner.
I want to give the user the ability to watch the pages like they are reading books by categories.
I would be happy to know - how can I add the article order number (for each category) inside the article itself.
I am sure that there is a PHP code that can do that.
Thanks so much for your help and assist.
Arye
You'll need to override the default article layout in your template.
If your template doesn't already have an article layout, you can copy the default layout from components/com_content/views/article/tmpl/default.php inside your template override templates\[YOURTEMPLATE]\html\com_content\article\default.php (replacing [YOURTEMPLATE] by your actual template name.
You can then display ordering where you require it within your template by using
<?php echo $this->item->ordering; ?>
You'll most likely want to either check for a certain condition (the article's category, perhaps) to determine whether you want to display the ordering.
Another option is to create an alternative layout instead of overriding the default one. You can rename default.php in your template to, let's say bookpage.php. You will then be able to pick the new layout as an alternative layout in your articles' options.
you can get article id by using
Request::getVar('id');
for more you can check the link
Joomla plugin : how to get article title and article id
for jquery you can do like this. you can create a function and call on every page load it will sort all your content accordingly. you can assign other attributes also in foreach loop.
<div id="allArticles">
<article id="3">Article 3</article>
<article id="1">Article 1</article>
<article id="2">Article 2</article>
</div>
$("#allArticles article").sort(function (a, b) {
return parseInt(a.id) > parseInt(b.id);
}).each(function(){
var elem = $(this);
elem.remove();
$(elem).appendTo("#allArticles");
});
more you can see the working example here http://jsfiddle.net/THMu3/

Magento checkout working except for progress boxes

I have recently been having problems with Magento's one page checkout system.
At the moment it is working in a basic way, but the progress steps which are normally displayed on the right hand side are not being updated when the steps are completed. The step headings are showing up (Billing Address, Shipping Address, etc.), and I can control their styles through the boxes.css settings, but they don't get filled in with the content as the customer step through the process.
I have tried a number of solutions, including:
changing the xml and
tweaking the opchecout.js file
What is the best way to debug something like this?
check that the ID of the block you insert matches the ID that is refreshed by the JavaScript function. I had that problem. If you are using the base/default/js/opcheckout.js file, it should be
id='checkout-progress-wrapper'
like so (in your onepage.phtml template):
<div id="checkout-progress-wrapper">
<?php echo $this->getChildHtml('checkoutProgress') ?>
</div>
Best if you check the js file also

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

assign image to category and it's posts on WordPress

I want to assign an image to a category and it's posts on WordPress. When adding the new post it will take the image and assign to it's container category. If you have any way to help or plug-in to do that, I would be really grateful.
Based on your question, I think you are trying to show posts (or maybe post excerpts) from multiple categories in a single list and include images in these posts based on their individual categories.
If there is only one place you are trying to display these images and if they will not change very often, you could include some conditionals directly in The Loop.
<!-- Test to see if the post is in a given cat and apply a custom class for styling -->
<?php if ( in_category('CATNUMBER') ) { ?>
<div class="SOME-CUSTOM-STYLE">
<?php } else { ?>
<div class="GENERIC-NON-STYLED-POST">
<?php } ?>
Once you have custom classes on the divs by category number, you can style a background image in your CSS. Alternately, you could spit out an tag right in the loop.
If you foresee adding new categories and/or changing pictures often, you will probably want a cleaner way of doing this. If you only have a handful of categories or if you are comfortable making changes to the loop often, this would work fine.

Resources