I am not a great programmer but want to translate my Dutch attributes on the category overview page. Currently it's like this:
Current Dutch attribute names :
Now I would like to translate "Merk" for example in the German version "Marke". I coded it like this:
<div class="price-box">
<?php if ($_product->getAttributeText('merk') != ''): ?>
<p class="availability in-stock opties"
style="margin-top: 15px; margin-bottom:8px;">
<?php echo $this->__('■ Merk:') ?>
<span>
<?php echo $_product->getAttributeText('merk') ?>
</span>
</p>
<?php endif; ?>
<?php if ($_product->getAttributeText('supdoelgroep') != ''): ?>
<p class="availability in-stock opties"
style="margin-top: 8px; margin-bottom:8px;">
<?php echo $this->__('■ Voor:') ?>
<span>
<?php echo $_product->getAttributeText('supdoelgroep') ?>
</span>
</p>
<?php endif; ?>
Does anyone know the php codes so I can fill in the translation per storeview?
You need to used magento default translate functionality.
For This :
<?php echo $this->__('Merk') ?>
Add like:
app/locale/{lang_ISO}/Mage_Catalog.csv
add value in this csv file like,
"Merk","Marke"
Related
I have setup a small webstore and I want to show this <div class ="data-plan"></div> only for one single product. My database table from where I want to match this id is called sb_files and it has these fields id table_id path type slide_link, so I am trying to get my code to go trough that table, search up the id ( Its 13040100 ) and if it matches then to show the div, else it shows an empty div. I am using the Yii2 framework, which is php based. So far I have tried this
<?php if($product->$this->id('13040100')): ?>
<ul>
<?php
$index = 1;
foreach($product->() as $prd):
if(strpos($prd->getPath(), '13040100') == true) {
?>
<div class="wrap">
<div class="data-plan" style="height:20px; width:65px; background-color:#00a651; float:right;color:white;margin:10px;text-align:center;">A+++ </div>
<div class="data-plan" style="height:20px; width:65px; background-color:#ed1c1c; float:right;color:white;margin:10px;">Datu lapa </div>
</div>
<?php
$index++;
}
endforeach;
?>
</ul>
<?php else: ?>
<div class="wrap">
</div>
<?php endif; ?>
I'm not that familiar with Yii2 framework myself, but are you sure that $product->$this->id('13040100') is correct? It looks weird to me, shouldn't it be something like $product->id('13040100')?
The solution was way easier than I tought, just had to think simple
<?php if ($product->id == '13001100'): ?>
<div class="wrap">
<div class="data-plan" style="height:20px; width:65px; background-color:#00a651; float:right;color:white;margin:10px;text-align:center;">A+++ </div>"
<div class="data-plan" style="height:20px; width:65px; background-color:#ed1c1c; float:right;color:white;margin:10px;">Datu lapa </div>
</div>
<?php else: ?>
<div class="wrap">
</div>
<?php endif;
I am working with Heroic Knowledge Base, and I am having trouble getting only one breadcrumb to show up (their suggested CSS code is not working). Unfortunately, I am not a PHP expert, and I am not sure how to edit the code so that it only shows one of the lines that it is pulling (we don't care which one) I have added the PHP from their breadcrumbs file. Any assistance would be greatly appreciated.
<?php
/**
* Breadcrumbs template
*/
?>
<?php if(hkb_show_knowledgebase_breadcrumbs()): ?>
<!-- .hkb-breadcrumbs -->
<?php $breadcrumbs_paths = ht_kb_get_ancestors(); ?>
<?php foreach ($breadcrumbs_paths as $index => $paths): ?>
<ol class="hkb-breadcrumbs" itemscope
itemtype="http://schema.org/BreadcrumbList">
<?php $last_item_index = count($paths)-1; ?>
<?php foreach ($paths as $key => $component): ?>
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<?php if($key==$last_item_index): ?>
<span itemprop="item">
<span itemprop="name"><?php echo
$component['label']; ?></span>
</span>
<?php else: ?>
<a itemprop="item" href="<?php echo $component['link']; ?>">
<span itemprop="name"><?php echo $component['label']; ?></span>
</a>
<?php endif; ?>
<meta itemprop="position" content="<?php echo $key+1; ?>" />
</li>
<?php endforeach; ?>
</ol>
<?php endforeach; ?>
I was able to solve this issue using the following code, however I would like to make it so that it is only effective when there is more than one.. the code below worked on articles with two breadcrumbs, but when there is only one it hid them all together.
ol.hkb-breadcrumbs {
display: table-column-group;
}
I'm facing a little problem, I have a css class which is called "negative margin" which I just want to apply once in the first div in a series of divs as it's part of my design. The code is as follows:
<?php foreach($records as $rec){ ?>
<div class="grid grid-lightgrey grid-pad negative-margin">
<div class="col-1-1">
<div class="module module-grey">
<em>Project title: <?php echo $rec->project_title; ?></em><br>
<em>Category: </em><?php echo $rec->project_category; ?><br>
<em>Description: </em><?php echo $rec->project_description; ?>
<br>
<em>This project was started in: <?php echo $rec->project_year; ?></em><br>
<em>This project ID is: </em>
<?php echo $rec->project_id; ?>
</div>
</div>
</div>
<?php } ?>
The class negative-margin is applied to all the divs making them stack on top of each other and it's not what I wan't but I need this negative margin to be applied in the first div as I said for design purposes but I really don't know how this could be achieved. Any ideas would be greatly appreciated.
Use the first-child selector to define a CSS style that only applies to the first div.
div.grid:first-child {
margin-left: -10px;
}
You need a variable to track the first element because there is no other way to know the index in foreach loop. You can do:
<?php $i = 0; foreach($records as $rec): ?>
<div class="grid grid-lightgrey grid-pad <?php echo ($i == 0) ? 'negative-margin' : ''; ?>">
<div class="col-1-1">
<div class="module module-grey">
<em>Project title: <?php echo $rec->project_title; ?></em><br>
<em>Category: </em><?php echo $rec->project_category; ?><br>
<em>Description: </em><?php echo $rec->project_description; ?>
<br>
<em>This project was started in: <?php echo $rec->project_year; ?></em><br>
<em>This project ID is: </em>
<?php echo $rec->project_id; ?>
</div>
</div>
</div>
<?php $i++; endforeach; ?>
I am trying to merge these 2 line of code for an if statement. The purpose is to hide the attribute if Code1 is blank. Each one reports correct but when place together the code give errors. Thanks for the hint :)
Code1
<?php if ($_product->getAttributeText('tempi_consegna') != '') ?>
Code2
<p class="availability in-stock"><?php echo $this->__('Consegna:') ?>
<span>
<?php echo $_product->getAttributeText('tempi_consegna') ?>
</span>
</p>
They should be living friendly in magento product availability.
You can try as following:
<?php if ($_product->getAttributeText('tempi_consegna') != ''): ?>
<p class="availability in-stock"><?php echo $this->__('Consegna:') ?>
<span>
<?php echo $_product->getAttributeText('tempi_consegna') ?>
</span>
</p>
<?php endif; ?>
I created a custom searchpage.tpl.php to print out search form and search results using the following code:
<div class="searchblock">
<?php
print drupal_get_form('search_form');
?>
</div>
<div class="search-result <?php print $search_zebra; ?>">
<dt class="title">
<?php print $title; ?>
</dt>
<dd>
<?php if ($snippet) : ?>
<p class="search-snippet"><?php print $snippet; ?></p>
<?php endif; ?>
</dd>
</div>
It shows the search form correctly and when I search a phrase, URL changes to http://domain.com/search/node/phrase
But it doesn't show the search results, How can I make it work please?
Here's the solution:
<div class="searchblock">
<?php
print drupal_get_form('search_form');
?>
</div>
<?php
$keys = arg(2);
print search_data($keys, $type = 'node');
?>
</div>