View Single Post
  #10  
Old October 30th, 2013, 08:17 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi
Quote:
Originally Posted by raj2006 View Post
I am using the 3-column layout from Template 1 under Product List with the code as below. What do you think should be corrected in this code to get the 3-column layout?
I'm seeing 3 columns now. I assume you got this fixed...



Quote:
Originally Posted by raj2006 View Post
Apart from the above issue of proper display of the 3-column layout, I just need one more help.

Instead of inserting the shortcode in each blog post, I have created a php code below to automate the process. Instead of the shortcode, I have tested it with the echo statement and the php is working per se.

But, the shortcode inside the php is breaking the code. How to correct it?

Code:
<?php
$categories = get_the_category();
foreach($categories as $category) { $cat_name = $category->slug; }

switch ($cat_name)
{
	case "adult-bibs":
		[DFR:Random Product in Post?c=1222595];
		break;
	case "gloves":
		[DFR:Random Product in Post?c=1202902];
		break;
	case "kids-aprons":
		[DFR:Random Product in Post?c=1202900];
		break;		
	case "kids-bibs":
		[DFR:Random Product in Post?c=1202901];
		break;			
	case "mens-aprons":
		[DFR:Random Product in Post?c=1202899];
		break;			
	case "womens-aprons":
		[DFR:Random Product in Post?c=1202898];
		break;
}			
?>
You need to use the PHP version of the Shortcode. So your code would look like this:

PHP Code:
<?php
$categories 
get_the_category();
foreach(
$categories as $category) { $cat_name $category->slug; }

switch (
$cat_name)
{
    case 
"adult-bibs":
        echo 
datafeedr_tag('Random Product in Post?c=1222595');
        break;
    case 
"gloves":
        echo 
datafeedr_tag('Random Product in Post?c=1202902');
        break;
    case 
"kids-aprons":
        echo 
datafeedr_tag('Random Product in Post?c=1202900');
        break;        
    case 
"kids-bibs":
        echo 
datafeedr_tag('Random Product in Post?c=1202901');
        break;            
    case 
"mens-aprons":
        echo 
datafeedr_tag('Random Product in Post?c=1202899');
        break;            
    case 
"womens-aprons":
        echo 
datafeedr_tag('Random Product in Post?c=1202898');
        break;
}            
?>
You can find out more about Shortcodes here: http://www.datafeedr.com/docs/item/185

Eric