Magento - Display image instead of another if body has a specific class - image

I need your help to do this with my Magento website.
In my header.phtml file I have this code that shows logo.
<img src='<?php echo $this->getLogoSrc(); ?>' alt='<?php echo $this->getLogoAlt(); ?>' />
This logo it's ok for all pages of the website, but I need to have another one logo (different colors) for the homepage.
Homepage body has this specific class "cms-home" that maybe we can use to detect the page.
This is the url of the image I want to show: http://www.mydomain.it/skin/frontend/neighborhood/child/images/gm-home.png
Many thanks

In the header you can use getIsHomePage in a PHP if else statement to determine if the current page is the homepage or not:
<?php if ($this->getIsHomePage()):?>
<img src='<?php echo $this->getLogoSrc(); ?>' alt='<?php echo $this->getLogoAlt(); ?>' />
<?php else:?>
<img src='<?php echo $this->getLogoSrc(); ?>' alt='<?php echo $this->getLogoAlt(); ?>' />
<?php endif; ?>
Just amend the src in the first to link to your alternative logo.

This worked for me!
<?php
if(
Mage::getSingleton('cms/page')->getIdentifier() == 'home' &&
Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms'
) : ?>
<img src='http://www.mydomain.it/skin/frontend/neighborhood/child/images/gm-home.png' alt='<?php echo $this->getLogoAlt(); ?>' />
<?php else:?>
<img src='<?php echo $this->getLogoSrc(); ?>' alt='<?php echo $this->getLogoAlt(); ?>' />
<?php endif; ?>

Related

Joomla/Jomsocial PinMe template I want to replace the PinMe Avatar with JomSocial's Profile image

Hi I am using TemPlaza's PinMe template with the Jomsocial community component in Joomla! 3.0.3 Stable [ Ember ]
What I am looking for a very simple solution to having the Jomsocial avatar (Profile Image) replace the PinMe image on the Pins which
uses joomla core for image and profile
Jomsocial offers this:
Use JomSocial Avatars
To acquire a path to a JomSocial Avatar, you can simply request a cUser object and call a simple getThumbAvatar function to retrieve the avatar url.
include_once JPATH_ROOT.'/components/com_community/libraries/core.php';
// Get CUser object
$user = CFactory::getUser($userid);
$avatarUrl = $user->getThumbAvatar();
echo '<img src="'.$avatarUrl.'">';
The PinMe template is coded as such:
<?php if(isset($this->s_user) && $this->s_user==1){ ?>
<div class="TzAuthor">
<?php if(isset($Pins->user_img) && !empty($Pins->user_img)){ ?>
<img class="tz_pin_img_user" src="<?php echo JUri::root().'/'.$Pins->user_img; ?>">
<?php }else{ ?>
<img class="tz_pin_img_user" src="<?php echo JUri::root().'/components /com_tz_pinboard/images/avata.jpg'?>">
<?php }?>
<div class="TzAuthorInfo">
<a class="tz_pin_name_user"
href="<?php echo Route::_(TZ_PinboardHelperRoute::getPinboardManageruserRoute($Pins->id_user)); ?>" rel="nofollow">
<?php echo $Pins->user_name; ?>
<?php if(isset($Pins->name_user_repin) && !empty($Pins->name_user_repin)){
?>
<strong class="tz_by">
<?php echo JText::_('COM_TZ_PINBOARD_MANAGERUSER_REPIN_BY'); ?>
</strong>
<?php
echo $Pins->name_user_repin;
}
?>
</a>
spoke with the PinMe people and the cost for custom code isnt worth it and the sites on my local not live
to reiterate
all I am looking for a very simple solution to having the Jomsocial avatar (Profile Image) replace the PinMe profile image on the Pins
how do i make this happen

Linking intro image in Joomla 3.3.1

I would like to turn all intro images on the blog layout to links to the articles just as read more does.
Found this post here:
Joomla 3.1 intro image as read more link
The solution here is to replace the code in default_item.php from this:
<img
<?php if ($images->image_intro_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/>
To this:
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>"><img
<?php if ($images->image_intro_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/> </a>
Followed the instructions, added an override folder in my template, copied default_item.php to it and made the change to the code. Nothing happened. I then tried to change the same lines in the component folder just to see if the problem was with the template override, nothing.
Is there another way of doing this?
Thanks in advance,
Guy.
default_item.php is only used as part of the featured articles view. If you are using the blog view, then the files appear under com_content/views/category/
The image itself is generated under com_content/views/category/blog_item.php on line 35
<?php echo JLayoutHelper::render('joomla.content.intro_image', $this->item); ?>
Change this to (via your template override)
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>">
<?php echo JLayoutHelper::render('joomla.content.intro_image', $this->item); ?>
</a>

I have a script, in yii. That almost does the job, need just a little push

I am not a programmer by any means. I purchased the script and have spent two weeks and many variations trying to get the code to do what I need. It is 'almost' there.
<div id="step-2" style="position:absolute; center:overflow-y:;">
<?php if($images): ?>
<?php foreach ($images as $img => $data): ?>
<a href="javascript:;" class="pin-img">
<img src="<?php echo $img ?>" />
</div>
</a>
<?php endforeach; ?>
<?php else: ?>
<h2><?php echo Yii::t('yii', 'No relevant found!') ?></h2>
<?php endif ?>
</div>
It returns the images from a site. It only lets me select the first image. Even though all images are displayed. Only one is actually clickable. If I hover over each of the images I see the javascript href. I understand that to be some sort of place holder. that just makes the browser show the hand.
I just need the script to allow each item to be a choice for reaction.
http://silenceisnotawkward.com/Sinapin/Script/# is the live code.
I have made a test user
Test=user
Password =password in case anyone wants to see what the site does.
http://www.ew.com/ew/ is a good link to pin from website and see the behavior.
I didn't look at your site, but looks like you are confusing your nesting of HTML tags, because you introduced a end-of-dev tag in your link.
<div id="step-2" style="position:absolute; center:overflow-y:;">
<?php if($images): ?>
<?php foreach ($images as $img => $data): ?>
<a href="javascript:;" class="pin-img">
<img src="<?php echo $img ?>" />
<!-- I removed the < / div > from here -->
</a>
:
<?php endforeach; ?>
</div
>
HINT: I indented the code to make it more readable, Try doing the same with your code you posted and see where it leads you.

related products in joomla

How to display only thumbnails of products in related products area, my current code is showing the link too i.e image tag with href title of product name. I just want to show the thumbnails
<?php
foreach($this->product->customfieldsRelatedProducts as $field) {
echo $field->display;
}
?>
I think code will help you.
<?php
$image_dir = JURI::root()."images/";
foreach($this->product->customfieldsRelatedProducts as $field) {
echo $field->display;
?>
<img src="<?php echo $image_dir.$field->image; ?>" alt="<?php echo $field->title ?>" />
<?php
}
?>

magento - multilingual site + Add store codes to url - want to show flag icons

I want to have a multi-language magento site use a flag image instead of a language selector box for user to select language of page. There is a nice article on this at http://www.atwix.com/magento/replace-language-selector-flag-icons/
Only issue is that we use "Add store codes to url" option. I hacked this code, but it can use some refinement and make it more Magento looking.
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<div class="langs-wrapper">
<?php foreach ($this->getStores() as $_lang): ?>
<?php if ($_lang->getCode() != 'default'): ?>
<?
$base_url = Mage::getBaseUrl();
// remove language in base url
$base_url = str_replace('/en/' , "" , $base_url);
$base_url = str_replace('/fr/' , "" , $base_url);
$current_url = $this->helper('core/url')->getCurrentUrl();
// take out base url and language code
$rest_of_url = str_replace($base_url , "" , $current_url);
$rest_of_url = str_replace('/en/' , "" , $rest_of_url);
$rest_of_url = str_replace('/fr/' , "" , $rest_of_url);
// assmble new url
$new_url = $base_url . '/' . $_lang->getCode() . '/' . $rest_of_url;
?>
<a class="lang-flag" href="<?php echo $new_url ;?>"><img src="<?php echo $this->getSkinUrl('images/flags/' . $_lang->getCode() . '.png');?>" alt=""></a>
<?php endif;?>
<?php endforeach;?>
</div>
</div>
<?php endif;?>
Template file (path/to/template/file.phtml):
<?php if(count($this->getStores()) > 1): ?>
<div class="form-language">
<?php foreach ($this->getStores() as $_lang): ?>
<?php $selected = $_lang->getId() == $this->getCurrentStoreId() ?>
<a class="lang-flag<?php $selected && print ' selected' ?>" href="<?php echo $_lang->getCurrentUrl() ?>">
<img src="<?php echo $this->getSkinUrl('images/flags/' . $_lang->getCode() . '.png');?>" alt="<?php echo $this->htmlEscape($_lang->getName()) ?>">
</a>
<?php endforeach ?>
</div>
<?php endif ?>
Add this lines to your layout-update xml file (if you haven't defined switch block):
<block type="page/switch" name="lang.switcher" template="path/to/template/file.phtml" />
If you have already one:
<reference name="store_language">
<action method="setTemplate"><tmpl>path/to/template/file.phtml</tmpl></action>
</reference>

Resources