Datafeedr Support Forums  

Go Back   Datafeedr Support Forums > Current Version (V3) Forum > Questions
Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Important - The support forums are now in "read-only" mode as we transition to an alternative help desk solution. Feel free to contact us here with any of your questions or search the forums for an existing solution.
 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 19th, 2012, 04:30 PM
lesljr lesljr is offline
 
Join Date: Jan 2012
Posts: 80
Default Assign PHP Variable to ShortCode

I figured out how to get related products into a widget. I just need to know how to assign a variable. Here is what I want to do. Thanks for your help

[DFR:Related Products?c=$dfr_category]


Store ID: 35889


<?php
$dfr_category = dfr_get_related_products();
?>

[DFR:Related Products]
  #2  
Old March 19th, 2012, 06:13 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

I'm not sure what you are going for. Can you explain more?
  #3  
Old March 19th, 2012, 07:08 PM
lesljr lesljr is offline
 
Join Date: Jan 2012
Posts: 80
Default

ok here is what I have done. 1st I create a custom field for my post called dfr_category_number. This way i can assign a category number to a post.

Then I created a php function(code below) to get the product category from the post.

Quote:
function dfr_get_related_products() {
$urlstr = $_SERVER['REQUEST_URI'];
$postidstr = url_to_postid( $urlstr );
return get_post_meta($postidstr, 'dfr_category_number', true);
}
Then I created a widget view to call dfr_get_related_products(code below)
Quote:
<?php
$dfr_category = dfr_get_related_products();
?>
[DFR:Related Products for Widget?c='$dfr_category']
Now inside the view I want to call a custom view using the dfr short code to get the related products. I have tested my php code, so I know that part works. i just need a way to dynamically call a view. The good thing about doing it this way is it will display related products in my sidebar if i have set it up, other wise it won't show any products.

Last edited by lesljr : March 19th, 2012 at 07:11 PM.
  #4  
Old March 19th, 2012, 08:00 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

As long as your dfr_get_related_products() function is returning an ID, then this PHP code should do the trick:

PHP Code:
<?php
$dfr_category 
dfr_get_related_products();
echo 
datafeedr_tag('Related Products for Widget?c='.$dfr_category);
?>
  #5  
Old March 19th, 2012, 08:16 PM
lesljr lesljr is offline
 
Join Date: Jan 2012
Posts: 80
Default

that worked. thanks. your a rock star!
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pagination with [DFR] Shortcode reimust Problems 1 November 20th, 2011 10:34 AM
Embedding shortcode in my sidebar erin Questions 5 November 14th, 2011 08:57 AM
How do assign a Custom Field to a Category? globalnet Questions 7 March 24th, 2011 11:07 AM
Assign Custom View to More Than 1 category? sgalusha Questions 1 January 18th, 2011 04:41 PM


All times are GMT -5. The time now is 12:55 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.