Datafeedr Support Forums

Datafeedr Support Forums (http://www.datafeedr.com/forums/index.php)
-   Questions (http://www.datafeedr.com/forums/forumdisplay.php?f=67)
-   -   How do I make unique title tags for price filter widget pages? (http://www.datafeedr.com/forums/showthread.php?t=3810)

cashnow January 28th, 2011 01:36 PM

How do I make unique title tags for price filter widget pages?
 
(I am using the filter by price widget in this question.)

I see that once I click on a filter by price link, the same category title is used in the price filter. I am wondering if there is a way to create a unique title based on the price as well as the current category.

This is a good example. They use the category name but also get under $50 into the title.



Store ID 6719
www.forbabygifts.com

Eric January 28th, 2011 01:55 PM

This works for me in the <head> elements:

PHP Code:

<?php
function format_price($price) {
    
$price strip_tags($price);
    
$price explode("-"$price);
    if (
trim($price[0]) == '')
        
$html 'less than $'.$price[1];
    elseif (
trim($price[1]) == '')
        
$html 'more than $'.$price[0];
    else
        
$html '$'.$price[0] . ' - ''$'.$price[1];
       
    return 
$html;
}
?>

<title>[category.name] | <?php if (@$_GET['price']) { ?> Price is <?php echo format_price($_GET['price']); ?> | <?php ?> </title>


cashnow January 28th, 2011 03:03 PM

In the filter by price widget head elements? I tried it there and do not see changes.

Any ideas?

Eric January 28th, 2011 03:04 PM

No, in the CATEGORY PAGE > Default > View menu > View <head> Elements section.

cashnow January 28th, 2011 03:26 PM

I have views created for my category pages. (I did try it in default but no dice).

I did it in one of my views, but when I added the price widget, my left navigation disappeared. You can see it here

This is what I added to the <head> elements of that view

<?php
function format_price($price) {
$price = strip_tags($price);
$price = explode("-", $price);
if (trim($price[0]) == '')
$html = 'less than $'.$price[1];
elseif (trim($price[1]) == '')
$html = 'more than $'.$price[0];
else
$html = '$'.$price[0] . ' - '. '$'.$price[1];

return $html;
}
?>

<title>Christening Rosaries | Christening Rosary Gift Ideas | [store.if page="on"] | page [store.page] | [/store.if]<?php if (@$_GET['price']) { ?> Price is <?php echo format_price($_GET['price']); ?> | <?php } ?> </title>

Eric January 28th, 2011 03:40 PM

I inserted your exact code into my test site and it worked fine.

You can see that it does work here where you have added the code to the <head> element.

Regarding your sidebar disappearing, are you sure it's related to the <head> code? Could it be something in your widget settings?

Eric

cashnow January 28th, 2011 04:01 PM

I think it is due to my widget settings. And your example looks great! That is exactly what I wanted.

cashnow January 28th, 2011 04:05 PM

But this is weird. If I use the tag cloud setting, my left nav stays with the tag cloud. When I switch it to price filter, my left navigation disappears.

Eric January 28th, 2011 04:09 PM

Are you clicking "Save" when you make an edit to the widgets on the WP widgets page?

cashnow January 28th, 2011 04:37 PM

Yes, and after I refresh the page, it vanishes.

Eric January 28th, 2011 04:43 PM

Are you using some type of widget context filter plugin?

cashnow January 28th, 2011 04:53 PM

I am using the Widget Context plugin. And I have it set to Show on Selected and store/category* assigned to it.

Eric January 28th, 2011 05:40 PM

What happens if you remove the extra <title> stuff that we did? Does the widget come back?

cashnow January 28th, 2011 05:52 PM

Yes, it does.

Eric January 28th, 2011 06:04 PM

Maybe try renaming the function call from format_price to forbabygifts_format_price. Maybe it's conflicting with another function.

PHP Code:

<?php
function forbabygifts_format_price($price) {
$price strip_tags($price);
$price explode("-"$price);
if (
trim($price[0]) == '')
$html 'less than $'.$price[1];
elseif (
trim($price[1]) == '')
$html 'more than $'.$price[0];
else
$html '$'.$price[0] . ' - ''$'.$price[1];

return 
$html;
}
?>

<title>Christening Rosaries | Christening Rosary Gift Ideas | [store.if page="on"] | page [store.page] | [/store.if]<?php if (@$_GET['price']) { ?> Price is <?php echo forbabygifts_format_price($_GET['price']); ?> | <?php ?> </title>


cashnow January 28th, 2011 06:11 PM

Tah-Da!!!!! .....and Thank you!!

Now, one last question, if I also want to do this with filter by merchant widget, is there a code for that as well?


All times are GMT -5. The time now is 03:58 AM.

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