I want to be able to add an image next to the title of an article (and be able to select the image for each article - not just a one and done setting). I modified the /administrator/components/com_content/models/forms/article.xml file by adding these fields at the top of the section:
<field
name="titleImage"
type="media"
label="Title Image"
description="Image that will be displayed next to the article's title." />
<field
name="spacer0"
type="spacer"
hr="true"
/>
This adds the parameter to the Edit Article page and lets me select an image.
I added this code to my theme's com_content/article/default.php page (inside the if ($params->get('show_title')) block):
<?php if($this->params->get('titleImage')){ ?>
<img class="titleImage" src="<?php echo htmlspecialchars($images->titleImage); ?>" alt="Title Image" />
<?php } ?>
The image is not appearing on the page. I'm new to Joomla so it may be obvious, but what am I missing?
Thanks!
In 2.5 there is already a standardized image field (actually 2) and all you have to really do is make a layout override to put the images where you want them.
YOu should modify the form using a plugin if you go that route. I would modify the image field to add a third image if you are already using the two of hem.
After some testing I found out why it wasn't working:
Firstly, you need to ensure you add the field to a specific place in article.xml. I would suggest adding it before or after <field name="show_title"> on line 127
Then, you can call the parameter like so:
<?php if ($params->get('titleImage')) : ?>
<img class="titleImage" src="<?php echo JURI::root() . $params->get('titleImage'); ?>" alt="Title Image" />
<?php endif; ?>
Hope this helps
Related
Hi guys wondering how I can manually add a link from Joomla intro article images to their corresponding article and also add a title tag to the link.
Ideally the way I want to do this is to for example wrap an achor tag around the image reference in the blog-item.php file (also want to achieve this for generic articles). And then within the anchor tag capture the related image alt tag and populate the title tag with that value.
Below is where I'm at. It's not currently working, not sure why as it should be pretty straight forward. I'm not a php developer, wondering what i'm missing.
Also already cleared both browser and joomla caches after my changes.
Any help would be appreciated, cheers guys
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>" title="<?php echo htmlspecialchars($images->image_intro_alt); ?>">
<img
src="<?php echo htmlspecialchars($images->image_intro); ?>"
alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/>
</a>
To make your code work, add just before your code.
<?php $images = json_decode($this->item->images); ?>
and your code will start working.
Already tested and it worked.
I am trying to create an image gallery on my real estate website that displays only the images associated with the property selected. I have the following code that allows me to bring up the images associated with the property. My issue now is trying to create an image gallery from this. Any ideas on how to do this? I am using Bootstrap 2.3.2 to build the site.
<?php
$path = "../uploads";
foreach (glob("$path/{$_SESSION['propertyid']}*") as $filename):
?>
<img src="<?php echo $path ?>/<?php echo $filename ?>" alt="photo" width="250" height="250" border="0" /><br><br>
<?php endforeach ?>
I would comment with this question and then answer this but I must have 50 rep to comment.
My question is why are you still using 2.3.2. Why not upgrade to 3.2? That is just pure curiosity. Regardless of the answer, I have had to do this before. I am not proficent with entering code correctly on stackoverflow yet so here is a pastebin link. BTW, I had to go digging through an old pastebin account for this.
http://pastebin.com/kPA6Vq0g
So, I'm using OpenCart 1.4.9.
What I want to do is grab a variable made by a custom shipping product.
The table in which it's coming from is product and the column is shipping_by_product:
I want to add a little picture when browsing through the categories so they can see it's free shipping.
Now, I was able to add this in the product detail (product.tpl template):
Using this code:
<?php if($product_info['shipping_by_product'] == '0.0000'){ ?>
<img src="LINK HERE" alt="Recommended by MADNESS">
<br />
<?php
}
?>
But that code doesn't work in category.tpl (The category template)
I get an undefined index error for $product_info and for shipping_by_product.
So I was thinking of just running a query to grab the information from the database and then add the conditional, or what other way can I do it?
Data is passed to the template by the controller, which gets it from the model (data layer). You might have to customize the controller and model to get that data if it isn't already passed. You can use the vqmod extension to add your own code in without changing the core code. Look here for info on the extension.
Figured it out.
Added: 'shipping_by_product' => $result['shipping_by_product'], to category.php
As I learned $result is pretty much the same as $product_info in this file.
Then I used this for my code:
<?php if($products[$j]['shipping_by_product'] == '0.0000'){ ?> <img style="position: absolute;margin-left: -100px;" src="IMAGE " alt="Free Continental US shipping!"> <br /> <?php } ?>
:)
I've installed some theme, which has header logo defined in header.phtml like this:
<img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" />
I don't really want to alter this template, also in that .phtml file it says not to edit it. How can I override this getLogoSrc most efficiently?
In the web admin, go to System>Configuration>Design and scroll down to Header>Logo Image Src. Insert the filename that you have saved in /skin/frontend/default/new_theme/images/ and click Save.
Go to your template's images folder e.g.: /skin/frontend/default/new_theme/images/
and replace the logo image in that folder with your new Logo
I want to change search image in magento. On search in magento the image name is btn_search.gif. Right now it take image from skin/frontend/default/default/images. And the file is /app/design/frontend/default/default/template/catalogsearch/form.mini.phtml where mention this tag as
<input id="search-button" type="image" src="<?php echo $this->getSkinUrl('images/btn_search.gif') ?>" alt="<?php echo $this->__('Search') ?>" />
I check the code and i found that we can pass locale as _type in this as
<input id="search-button" type="image" src="<?php echo $this->getSkinUrl('images/btn_search.gif', array('_type'=>'local')) ?>" alt="<?php echo $this->__('Search') ?>" />
But when i check the code this will just check in locale directory that this file exist in that locale or not. If this exist then it will take skin image. I want to use that locale image instead of that skin image.
So when i click on french store i get the image which is i set in /app/design/frontend/default/default/locale/fr_FR/images/btn_search.gif
I check the code for getSkinUrl in /app/code/core/Mage/Core/Model/Design/Package.php. And i found that he check locale for file but it return skin url.
Is there any method which return locale url ?
I got the answer
This is how I have made the buttons language (locale) dependent within magento commerce
I started with the mini-search form on the homepage. The search image button for that form is defined in
/app/design/frontend///template/catalogsearch/form.mini.phtml
In that file i’ve changed the following line
<input type="image" src="<?php echo $this->getSkinUrl('images/btn_mini_search.gif') ?>" alt="<?php echo $this->__('Search') ?>"/>
to
<input type="image" src="<?php echo $this->getSkinUrl('images/btn_mini_search_'.$this->__('_LOCALE_BUTTON_').'.gif') ?>" alt="<?php echo $this->__('Search') ?>"/>
Then I added the translation for _LOCALE_BUTTON_ to all the the locale translate.csv files:
/app/design/frontend///locale//translate.csv:
I.e.
Locale en_GB: _LOCALE_BUTTON_,en_GB
Locale nl_NL: _LOCALE_BUTTON_,nl_NL
For each translation make sure you have the locale suffix button image files available in the /skin/frontend///images/ directory:
I.e.
btn_mini_search_en_GB.gif
btn_mini_search_nl_NL.gif
I think you can also make the translation for _LOCALE_BUTTON_ to represent a folder by changing the line mentioned above to:
<input type="image" src="<?php echo $this->getSkinUrl('images/locale/'.$this->__('_LOCALE_BUTTON_').'/btn_mini_search.gif') ?>" alt="<?php echo $this->__('Search') ?>"/>
but then you need to save the locale suffix button image files like this:
/skin/frontend///images/ locale/en_GB/btn_mini_search.gif and
/skin/frontend///images/ locale/nl_NL/btn_mini_search.gif
I haven’t tested the last method myself, but I don’t see any reasons why it shouldn’t work.
I’ve also been thinking about replacing the _LOCALE_BUTTON_ value with the regular ‘Search’ string (Not recommended!!)
The advantage of this method is that you don’t need to add seperate translations to the translate.csv files but then you run the risk that certain translations can be similar for multiple locales (duplicate keys). Besides that it can lead to issues, when non-ascii/utf-8 characters are used in the translations, but that depends on the operating/file system you are using.