Multilingual slideshow - php

I have this code for a slideshow in my Drupal 7, Nexus 7.x-1.3 theme.
My website is multilingual and I need to use a different image for every language, eg. I would like to change slide-image-1.jpg (en language) with other image-name for (gr language).
My code:
<?php if ($is_front): ?>
<?php if (theme_get_setting('slideshow_display','nexus')): ?>
<?php
$slide1_head = check_plain(theme_get_setting('slide1_head','nexus')); $slide1_desc = check_markup(theme_get_setting('slide1_desc','nexus'), 'full_html'); $slide1_url = check_plain(theme_get_setting('slide1_url','nexus'));
$slide2_head = check_plain(theme_get_setting('slide2_head','nexus')); $slide2_desc = check_markup(theme_get_setting('slide2_desc','nexus'), 'full_html'); $slide2_url = check_plain(theme_get_setting('slide2_url','nexus'));
$slide3_head = check_plain(theme_get_setting('slide3_head','nexus')); $slide3_desc = check_markup(theme_get_setting('slide3_desc','nexus'), 'full_html'); $slide3_url = check_plain(theme_get_setting('slide3_url','nexus'));
?>
<div id="slidebox" class="flexslider">
<ul class="slides">
<li>
<img src="<?php print base_path() . drupal_get_path('theme', 'nexus') . '/images/slide-image-1.jpg'; ?>"/>
<?php if($slide1_head || $slide1_desc) : ?>
<div class="flex-caption">
<h2><?php print $slide1_head; ?></h2><?php print $slide1_desc; ?>
<a class="frmore" href="<?php print url($slide1_url); ?>"> <?php print t('CONTACT US'); ?> </a>
</div>
<?php endif; ?>
</li>
<li>
<img src="<?php print base_path() . drupal_get_path('theme', 'nexus') . '/images/slide-image-2.jpg'; ?>"/>
<?php if($slide2_head || $slide2_desc) : ?>
<div class="flex-caption">
<h2><?php print $slide2_head; ?></h2><?php print $slide2_desc; ?>
<a class="frmore" href="<?php print url($slide2_url); ?>"> <?php print t('CONTACT US'); ?> </a>
</div>
<?php endif; ?>
</li>
<li>
<img src="<?php print base_path() . drupal_get_path('theme', 'nexus') . '/images/slide-image-3.jpg'; ?>"/>
<?php if($slide3_head || $slide3_desc) : ?>
<div class="flex-caption">
<h2><?php print $slide3_head; ?></h2><?php print $slide3_desc; ?>
<a class="frmore" href="<?php print url($slide3_url); ?>"> <?php print t('CONTACT US'); ?> </a>
</div>
<?php endif; ?>
</li>
</ul><!-- /slides -->
<div class="doverlay"></div>
</div>
<?php endif; ?>
<?php endif; ?>
Is there any solution for that? Thank you.

There is a Drupal connector from Smartling that may be of help. Here is a video showing how the connector works.
Many sites running on Smartling do language/country-specific image replacement, which is explained here.
Hope this helps,
Nataly

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<SCRIPT>
function english(){
$(#image).attr('src','http://link.to.your/english/image.png')
}
function greek(){
$(#image).attr('src','http://link.to.your/greek/image.png')
}
</SCRIPT>
<IMG id="image" src="http://link.to.your/greek/image.png">
Change to English<BR>
Change to Greek

Finally I fixed it in page.tpl with php code. One if/else on your page language to set you picture path.
Regards, HashKey

Related

PHP: link a Block

quick question, i want to link the BLOCK1 to another page. Is it possible? do anyone got a solution? i have tried abit and my brain is going mad T_T. there are 5 other blocks that i which to link to other pages aswell.
this is the code below:
<div class="midrow_block axn_block1">
<div class="mid_block_content">
<!--BLOCK1 IMAGE-->
<?php if(!empty($optimizer['block1_image']['url']) && empty($optimizer['block1_img_bg'])){ ?>
<div class="block_img"><img src="<?php echo $optimizer['block1_image']['url']; ?>" width="<?php echo $optimizer['block1_image']['width']; ?>" height="<?php echo $optimizer['block1_image']['height']; ?>" /></div>
<?php } ?>
<div class="block_content">
<h3>
<?php echo do_shortcode( $optimizer['block1_text_id']); ?>
</h3>
<?php echo do_shortcode($optimizer['block1_textarea_id']); ?>
</div>
</div>
</div>
</div>
<?php } ?>
<!--BLOCK1 END-->
Just put a <a>-Tag arount the block you want to link:
<a href="'your link here'"> <!-- start link here -->
<div class="midrow_block axn_block1">
<div class="mid_block_content">
<!--BLOCK1 IMAGE-->
<?php if(!empty($optimizer['block1_image']['url']) && empty($optimizer['block1_img_bg'])){ ?>
<div class="block_img"><img src="<?php echo $optimizer['block1_image']['url']; ?>" width="<?php echo $optimizer['block1_image']['width']; ?>" height="<?php echo $optimizer['block1_image']['height']; ?>" /></div>
<?php } ?>
<div class="block_content">
<h3>
<?php echo do_shortcode( $optimizer['block1_text_id']); ?>
</h3>
<?php echo do_shortcode($optimizer['block1_textarea_id']); ?>
</div>
</div>
</div>
</a> <!-- end link here -->
Or put it around any other part you want to have the link on. It's just basic HTML and has nothing to do with PHP.
here is the fullcode of the block. i missed to copy the top of it:
<?php if ((!empty ($optimizer['block1_text_id'])) || (!empty ($optimizer['block1_textarea_id'])) ) { ?>
<div class="midrow_block axn_block1">
<div class="mid_block_content">
<!--BLOCK1 IMAGE-->
<?php if(!empty($optimizer['block1_image']['url']) && empty($optimizer['block1_img_bg'])){ ?>
<div class="block_img"><img src="<?php echo $optimizer['block1_image']['url']; ?>" width="<?php echo $optimizer['block1_image']['width']; ?>" height="<?php echo $optimizer['block1_image']['height']; ?>" /></div>
<?php } ?>
<div class="block_content">
<h3>
<?php echo do_shortcode( $optimizer['block1_text_id']); ?>
</h3>
<?php echo do_shortcode($optimizer['block1_textarea_id']); ?>
</div>
</div>
</div>
You can use with this JS
<div class="midrow_block axn_block1" onclick="location.href='url'">content</div>
jQuery:
$("div").click(function(){
window.location=$(this).find("a").attr("href"); return false;
});

PHP foreach - Creating multple searchs in the same page

Firstly, I am a total php newby.
Secondly, below is the php header plus corresponding recursive commands for 2 photo lightboxes that are in the same html page.
Without the lines
getRecords() as $Title_row){ ?>
The page shows shows the first picture that is held in the external db table in the lightbox correctly.
Yet when I add the line below to add all the other entries in each table
getRecords() as $Title_row){ ?>
the page goes white and the browser html return is empty.
As I do not really understand what I am doing, I am stuck. Any suggestions would be very welcome.
<?php
$Title_find = $Lowdenphotoweb->newFindCommand('MASTER_photo');
$Title_findCriterions = array('Order_web'=>'*',);
foreach($Title_findCriterions as $key=>$value) {
$Title_find->AddFindCriterion($key,$value);
}
fmsSetPage($Title_find,'Title',50);
$Title_find->addSortRule('Order_web',1,FILEMAKER_SORT_ASCEND);
$Title_result = $Title_find->execute();
if(FileMaker::isError($Title_result)) fmsTrapError($Title_result,"error.php");
fmsSetLastPage($Title_result,'Title',50);
$Title_row = current($Title_result->getRecords());
?>
<?php
$Title1_find = $Lowdenphotoweb->newFindCommand('MASTER_photo');
$Title1_findCriterions = array('Order_web'=>'*',);
foreach($Title1_findCriterions as $key=>$value) {
$Title1_find->AddFindCriterion($key,$value);
}
fmsSetPage($Title1_find,'Title',50);
$Title1_find->addSortRule('Order_web',1,FILEMAKER_SORT_ASCEND);
$Title1_result = $Title1_find->execute();
if(FileMaker::isError($Title1_result)) fmsTrapError($Title1_result,"error.php");
fmsSetLastPage($Title1_result,'Title',50);
$Title1_row = current($Title1_result->getRecords());
?>
<!DOCTYPE html>
<!-- Lightbox Gallery -->
<?php foreach($Title_result->getRecords() as $Title_row){ ?>
<div class="hide">
<a data-group="gallery-1" data-caption="<?php echo $Title_row->getField('Title'); ?>" href="<?php echo $Title_row->getField('Pic_location'); ?>"></a>
</div>
<?php foreach($Title2_result->getRecords() as $Title2_row){ ?>
<div class="hide">
<a data-group="gallery-2" data-caption="<?php echo $Title2_row->getField('Title'); ?>" href="<?php echo $Title2_row->getField('Pic_location'); ?>"></a>
</div>
<!-- Lightbox Gallery End-->
You just missed out the closing brackets :
<?php foreach($Title_result->getRecords() as $Title_row){ ?>
<div class="hide">
<a data-group="gallery-1" data-caption="<?php echo $Title_row->getField('Title'); ?>" href="<?php echo $Title_row->getField('Pic_location'); ?>"></a>
</div>
<?php }?>
<?php foreach($Title2_result->getRecords() as $Title2_row){ ?>
<div class="hide">
<a data-group="gallery-2" data-caption="<?php echo $Title2_row->getField('Title'); ?>" href="<?php echo $Title2_row->getField('Pic_location'); ?>"></a>
</div>
<?php }?>

Page goes blank after adding to PHP foreach

Hello after I add some code to this PHP foreach the page goes blank and all I can see is a round black dot at the top left of screen.
My website is in Joomla3 and I am trying to customize a module. my site is http://get2gethersports.com
I have a recent post module that only shows the articles title.
that code is posted below
<?php if ($items) { ?>
<ul class="rsblog-recent-module unstyled<?php echo $params->get('moduleclass_sfx',''); ?>">
<?php foreach ($items as $item) { ?>
<li>
<a <?php echo $opener; ?> href="<?php echo JRoute::_('index.php?option=com_rsblog&view=post&id='.RSBlogHelper::sef($item->id,$item->alias).$Itemid,false); ?>">
<?php echo $item->title; ?>
</a>
</li>
<?php } ?>
</ul>
<?php } ?>
I would like to add an image abocve like the blog feed on http://vape-co.com
So I navigated to the component and saw the call for the image. which is posted below:
<div class="rsblog-entry-content">
<?php if ($this->item->image) { ?>
<div class="rsblog-entry-image">
<img class="rsblog-entry-thumb img-polaroid" src="<?php echo JURI::root().'components/com_rsblog/assets/images/blog/'.$this->item->image; ?>?nocache=<?php echo uniqid(''); ?>" alt="<?php echo $this->escape($this->item->title); ?>">
</div>
<?php } ?>
but whenever i add it or a snippet of it to the previous code it breaks....
Any ideas why it is breaking the page and how to fix it?
I tried adding in new li tags. Just adding the PHP part above the a link etc...
CODE UPDATE----
<?php if ($items) { ?>
<ul class="rsblog-recent-module unstyled<?php echo $params->get('moduleclass_sfx',''); ?>">
<?php foreach ($items as $item) { var_dump($item);?>
<li>
<div class="rsblog-entry-content">
<?php if ($this->item->image) { ?>
<div class="rsblog-entry-image">
<img class="rsblog-entry-thumb img-polaroid" src="<?php echo JURI::root().'components/com_rsblog/assets/images/blog/'.$this->item->image; ?>?nocache=<?php echo uniqid(''); ?>" alt="<?php echo $this->escape($this->item->title); ?>">
</div>
</div>
<?php } ?>
<a <?php echo $opener; ?> href="<?php echo JRoute::_('index.php?option=com_rsblog&view=post&id='.RSBlogHelper::sef($item->id,$item->alias).$Itemid,false); ?>">
<?php echo $item->title; ?>
</a>
</li>
<?php } ?>
</ul>
<?php } ?>
Try $item->image instead of $this->item->image
Correct code. Looks like it just needed some reduction.
<?php if ($items) { ?>
<ul class="rsblog-recent-module unstyled<?php echo $params -> get('moduleclass_sfx',''); ?>">
<?php foreach ($items as $item) { ?>
<li>
<?php if($item->image != '') ?>
<img src="components/com_rsblog/assets/images/blog/<?php echo $item->image;?>" alt="<?php echo $item->title. "logo";?>" width="100px"/>
<br/>
<a <?php echo $opener; ?> href="<?php echo JRoute::_('index.php?option=com_rsblog&view=post&id='.RSBlogHelper::sef($item->id,$item->alias).$Itemid,false); ?>">
<?php echo $item->title; ?>
</a>
</li>
<?php } ?>
</ul>
<?php } ?>

substr not working with $item->getTitle

I'm making a website with Joomla and am using RokSprocket to display some news. Now, some Titles are too long, so I wanted to shorten it after a certain character number, but it's not working. Am a total php noob, my apologies.
Here's the whole code:
<li data-lists-item>
<h4 class="sprocket-lists-title ">
<?php if ($item->custom_can_have_link): ?><a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>"><?php endif; ?>
<?php if(strlen($item->getTitle)>10)
echo substr($item->getTitle,0,10) . ' ...';
else
echo $item->getTitle();?></a>
<div class="date"><?php echo date('d.M. Y', strtotime($item->getDate()));?></div>
</h4>
<span class="sprocket-lists-item" data-lists-content>
<span class="sprocket-padding">
<?php if ($item->getPrimaryImage()) :?>
<img src="<?php echo $item->getPrimaryImage()->getSource(); ?>" class="sprocket-lists-image" />
<?php endif; ?>
<?php echo $item->getText(); ?>
<?php if ($item->getPrimaryLink()) : ?>
<span><?php rc_e('READ_MORE'); ?></span>
<?php endif; ?>
</span>
</span>
</li>
I'm hoping it's something very obvious and I'm just being stupid. Thanks a bunch already!
$item->getTitle is probably a method not a property, so try:
$item->getTitle(); // <-- parenthesis
Change to:
<?php if(strlen($item->getTitle())>10)
echo substr($item->getTitle(),0,10) . ' ...';

Put an image on top of another one with php and html

I have a magento store with a custom attribute called free shipping
Right now this renders a free shipping icon below the product itself
But I want to make it more appealing by putting a new button on top of the product itself.
Here is the php code for the magento page:
Sample of how a page is rendered:
http://www.theprinterdepo.com/lexmark-optra-t640-printer-20g0100
I need to modify the code in gallery.phtml to put the icon on TOP of the product, RIGHT top corner.
I will modify the image to be transparent.
This is gallery.phtml file:
<?php $_width=$this->getImageWidth() ?>
<div class="product-image-popup" style="width:<?php echo $_width; ?>px;">
<p class="a-right"><?php echo $this->__('Close Window') ?></p>
<?php if($this->getPreviusImageUrl() || $this->getNextImageUrl()): ?>
<div class="nav">
<?php if($_prevUrl = $this->getPreviusImageUrl()): ?>
« <?php echo $this->__('Prev') ?>
<?php endif; ?>
<?php if($_nextUrl = $this->getNextImageUrl()): ?>
<?php echo $this->__('Next') ?> »
<?php endif; ?>
</div>
<?php endif; ?>
<?php if($_imageTitle = $this->htmlEscape($this->getCurrentImage()->getLabel())): ?>
<h1 class="image-label"><?php echo $_imageTitle ?></h1>
<?php endif; ?>
<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $this->getImageFile()); ?>"<?php if($_width): ?> width="<?php echo $_width ?>"<?php endif; ?> alt="<?php echo $this->htmlEscape($this->getCurrentImage()->getLabel()) ?>" title="<?php echo $this->htmlEscape($this->getCurrentImage()->getLabel()) ?>" id="product-gallery-image" class="image" />
<?php if($this->getPreviusImageUrl() || $this->getNextImageUrl()): ?>
<div class="nav">
<?php if($_prevUrl = $this->getPreviusImageUrl()): ?>
« <?php echo $this->__('Prev') ?>
<?php endif; ?>
<?php if($_nextUrl = $this->getNextImageUrl()): ?>
<?php echo $this->__('Next') ?> »
<?php endif; ?>
</div>
<?php endif; ?>
<p class="a-right"><?php echo $this->__('Close Window') ?></p>
</div>
<script type="text/javascript">
//<![CDATA[
Event.observe(window, 'load', function(){
var demensions = $('product-gallery-image').getDimensions();
window.resizeTo(demensions.width+90, demensions.height+210);
});
//]]>
</script>
This is view.phtml
<?php $Deal = $_product->getResource()->getAttribute('deal')->getFrontend()->getValue($_product);?>
<?php $onSale = $_product->getResource()->getAttribute('on_sale')->getFrontend()->getValue($_product);?>
<?php $hotItem = $_product->getResource()->getAttribute('hot_item')->getFrontend()->getValue($_product);?>
<?php $freeShip = $_product->getResource()->getAttribute('free_shipping')->getFrontend()->getValue($_product);?>
<?php if($Deal == 'Yes'){ ?>
<img src="<?php echo $this->getSkinUrl('images/depot/icon-deal.gif') ?>" >
<?php } ?>
<?php if($onSale == 'Yes'){ ?>
<img src="<?php echo $this->getSkinUrl('images/depot/icon-sale.gif') ?>" >
<?php } ?>
<?php if($hotItem == 'Yes'){ ?>
<img src="<?php echo $this->getSkinUrl('images/depot/icon-hot.gif') ?>" >
<?php } ?>
<?php if($freeShip == 'Yes'){ ?>
<img src="<?php echo $this->getSkinUrl('images/depot/icon-freeship.gif') ?>" >
<?php }?>
Don't know a great deal about Magento but what you are talking about will require CSS coding not really PHP. Ideally you will need both images output to the same container DIV.
Then set the images to position: absolute and then use zindex to stack them on top of each other. Note the container div will either need to be position: absoloute or position: relative for the positioning of the images to work properly.
See here for more - How can we overlap two images using css style?

Categories