I would like to please your help.
I want to echo an attribute that I created Brand which is a Visual swatch (i use Ajax Layered Navigation, so I have an option with text and Swatch image).
I manage to echo each product the brand text that belongs but I can't echo the image.
Can you please help me?
<?php $attributeValue = $_product->getAttributeText('manufacturer'); ?>
<?php if(strlen($attributeValue) > 0): ?>
<?php echo $attributeValue; ?>
<?php endif; ?>
Related
I am currently writing a node server, using express and ejs for the tempting engine. Some of my .ejs files have 7 - 8 include statements for partials nested inside of them. I was wondering if this is resource intensive, or if it will be fine.
EJS maintainer here.
First off, if you're reading the same file many times in a row, the filesystem will cache it on that level.
However, if you want maximum performance, set cache: true in the options. (docs) You must be using renderFile() or passing in the filename to get this to work. If you're using Express, cache: true is set automatically when NODE_ENV is set to production.
Keep in mind that this assumes that your files never change. i.e. if you change a file, EJS will just use the old cached version until you restart the server process.
I've tested the include load time for 29 partials:
<!DOCTYPE html>
<html lang="en">
<? console.time('ejsIncludeTime') ?>
<?include ../partials/head ?>
<body>
<? include ../partials/header ?>
<? include ../partials/a ?>
<? include ../partials/b ?>
<? include ../partials/c ?>
<? include ../partials/d ?>
<? include ../partials/e ?>
<? include ../partials/f ?>
<? include ../partials/g ?>
<? include ../partials/h ?>
<? include ../partials/i ?>
<? include ../partials/j ?>
<? include ../partials/k ?>
<? include ../partials/l ?>
<? include ../partials/m ?>
<? include ../partials/n ?>
<? include ../partials/o ?>
<? include ../partials/p ?>
<? include ../partials/q ?>
<? include ../partials/r ?>
<? include ../partials/s ?>
<? include ../partials/t ?>
<? include ../partials/u ?>
<? include ../partials/v ?>
<? include ../partials/w ?>
<? include ../partials/x ?>
<? include ../partials/y ?>
<? include ../partials/z ?>
<? include ../partials/footer ?>
<? console.timeEnd('ejsIncludeTime') ?>
</body>
</html>
Each partial from a-z contains 120 or more lines of html. Here's how it goes:
First hit after the server restart ejsIncludeTime: 0.175ms
Consequent hits ejsIncludeTime: 0.078ms, 0.068ms, 0.058ms, 0.067ms, 0.077ms
Restart the server again and hit ejsIncludeTime: 0.157ms
Consequent hits 0.168ms(hit after a few minutes gap), 0.044ms, 0.052ms
It therefore appears that there's caching involved on some level. The first hit always takes 0.150+ms of include time. Consequent hits are always much less time consuming except for an occasional peak like 0.168ms (can't really explain why. Maybe cache miss).
I need to render contact form field elements using form_alter function.
When I print $content variable in tpl file, the contact form loads entirely, instead of that I need to render fields separately like drupal_render(drupal_get_form(form['name'])).
For Drupal 7, you can refer to /modules/node/node.tpl.php as an example. Here is a code snippet in the file:
<div class="content"<?php print $content_attributes; ?>>
<?php
// We hide the comments and links now so that we can render them later.
hide($content['comments']);
hide($content['links']);
print render($content);
?>
</div>
<?php print render($content['links']); ?>
<?php print render($content['comments']); ?>
I'm not sure if there is difference in Drupal 6, but you can try.
as i understand, nested areablock are possible since long. but something's not working.
lets say we have two areas, one called 'nested' and one called 'text'.
this is view.php for text:
<div>
<?php echo $this->wysiwyg("content_wysiwyg"); ?>
</div>
this is view.php for 'nested':
<div>
<?php while($this->block('index')->loop()) { ?>
<div>
<?php echo $this->areablock('index_block'); ?>
</div>
<?php } ?>
</div>
i create a page, and insert the areas like this:
nested 1
text 1
nested 2
text 1.1
when i preview the page everything is fine. but when i view the same page without pimcore_preview=true text 1.1 is not displayed. the divs are there so the template gets included, but the content is missing.
what's going on here?
I had similar problem today.
Viz. I had problem with visibility of any editable item in front end.
You need to clear your cache and that's it.
I am stuck on how to create a breadcrumb menu in my wordpress so that when I select the main menu, the path shows its first inner menu. For example I have a main menu About us and Company Profile as its child. When I am select the About us, I want to get the Compony profile page and also the breadcrumb like About us / Company profile. Is there any way to do so? any plugins? I currently using Breadcrumb NavXT plugin for creating breadcrumb
You can add breadcrumb without using any plugin like this. Please add below code into your themes functions.php file.
function breadcrumbs($id = null){
?>
<div id="breadcrumbs">
Home</span> >
<?php if(!empty($id)): ?>
<a href="<?php echo get_permalink( $id ); ?>" ><?php echo get_the_title( $id ); ?></a> >
<?php endif; ?>
<span class="breadcrumb_last"><?php the_title(); ?></span>
</div>
<?php }
Now whenever you want to add breadcrumb just call this function like this.
<?php breadcrumbs(); ?>
As you mentioned above you have to add about page id into this function and call this to company profile page if this page is child page of about page than this works.
<?php breadcrumbs($id); ?>
How to display custom CCK field (text or imagefield) in Drupal core search results page?
You need to override search-result-tpl.php in your theme. Copy it from modules/search to your themes directory, clear the theme cache, and you're set. You'll see that there is an array available to the theme file called 'result', which contains a bunch of data, including a node object. So your file becomes something like:
<dt class="title">
<?php print $title; ?>
</dt>
<dd>
<?php
// Here is the change
print $result['node']->field_name_of_cck_field['view'];
?>
<?php if ($snippet) : ?>
<p class="search-snippet"><?php print $snippet; ?></p>
<?php endif; ?>
<?php if ($info) : ?>
<p class="search-info"><?php print $info; ?></p>
<?php endif; ?>
</dd>
Good luck!
1 Copy search-result.tpl.php file from modules/search to your theme folder
2 For CCK text field add:
<?php if ($result['node']->field_name[0]['value']): ?>
<h4><?php print($result['node']->field_name[0]['value']); ?></h4>
<?php endif; ?>
3 For imagefield with imagecache:
<?php if ($result['node']->field_logo[0]['filename']): ?>
<img src="/sites/default/files/imagecache/path_to_file/<?php print $result['node']->field_logo[0]['filename']; ?>" />
<?php endif; ?>
4 CSS styling next.
Thanx for cam8001 & googletorp!
It depends how you do the search.
If you use views to build a search, you can decide yourself what to show.
If you're using some other search mechanics, you can use a combination of a proprocess hook, theming function, template you get the output you want. You should have the node object available, so displaying a CCK should be easy enough.
Edit:
For the Drupal core search module you need to overwrite the search-result.tpl.php in your theme, to alter how search results are printed. Here you can add or delete info. If you need more variables, you can create them for use in the template in a process hook. This is basic Drupal theming, check out the handbook.