Datafeedr Support Forums

Datafeedr Support Forums (/index.php)
-   Questions (/forumdisplay.php?f=67)
-   -   Change button link destination? (/showthread.php?t=9235)

DohRayMi June 15th, 2013 05:13 PM

Change button link destination?
 
Hi guys,
a bit of a long shot I know, but is there any way of changing the destination of the More Info button to a custom post type instead of the Store?

Or, instead of that, what would work for me is if I could imbed emded a link to where I want in each merchant's logo, and that link wasn't lost when the product list was displayed.
So I want to have a product list, and the only link in each product would be the logo, which would click through to my custom post type (which is a page dedicated to that merchant).
Hope that makes sense.

Thank you,
Philip.

Eric June 15th, 2013 08:09 PM

Hi Philip,

The only way you can do that is to first map all merchant IDs to custom post type IDs. Then create a PHP function that handles the mapping. Then replace the links in the Factory with a call to the PHP function you created and pass in the merchant ID.

Eric

DohRayMi June 16th, 2013 03:40 AM

OK Eric,

thanks. I sort of get the idea, but it's too complicated for me to do.

Does anyone on here offer customisation of this type?

Cheers,
Philip.

Eric June 16th, 2013 08:34 AM

Hi,

This could help. Place the following into your theme's functions.php file:
PHP Code:

<?php
function map_mid_to_cpt$merchant_id ) {
    
$map = array(
        
12345 => get_permalink),
        
23456 => get_permalink),
        
34567 => get_permalink),
        
45678 => get_permalink),
        
56789 => get_permalink),
    );
    return 
$map[$merchant_id]; 
}
?>

12345, 23456, 34567, etc represent the Datafeedr merchant ID.
1, 2, 3, 4, 5 represent the ID of the post or page about that merchant. See http://codex.wordpress.org/Function_.../get_permalink for more info.

Then in your Views you would do something like this:
HTML Code:

<a href="<?php echo map_mid_to_cpt( $product->merchant_id ); ?>">More info</a>
Eric

DohRayMi June 17th, 2013 05:38 AM

Hi,
thanks very much for that Eric, much appreciated.

Unfortunately, I can't get it to point to the correct URL, though it is picking up the correct merchant OK.

Depending on where I put it, it either points to

Mysite.com/storehomepage?merchant_id=XXXX

or

mysite.com/merchantname/

neither of which is a valid URL.

So it looks like it's going to work, if I can figure out how to incorporate the ID properly for my site.

Thanks,
Philip.

DohRayMi June 17th, 2013 08:09 AM

Ooops,
had to remove that code from functions.php as I couldn't log in again while it was there.
Philip.

Eric June 17th, 2013 08:37 AM

Hi,

What's the post ID and URL of a page about a single merchant?

Make sure you either include and/or exclude the opening and/or closing php tags (ie. <?php and ?>) properly when placing that code into your functions.php file to prevent the code from breaking your log in functionality.

Eric

DohRayMi June 17th, 2013 08:51 AM

Hi Eric,
I just copied the entire code into the functions file, after and seperate from everything else.

Here's an example merchant page

http://www.dohraymi.com/city/na/onli...ed-mp3-players
The post ID is 7903
The Datafeedr Merchant ID is 8303

Thank you,
Philip.

Eric June 17th, 2013 08:57 AM

Hi,

So for those IDs, you'd have:

PHP Code:

function map_mid_to_cpt$merchant_id ) {
    
$map = array(
        
8303 => 7903,
    );
    return 
get_permalink$map[$merchant_id] ); 


I also modified the code just a bit.

Eric

DohRayMi June 17th, 2013 09:33 AM

Hi again,
thank you.
So I take a new line for each merchant and put the 2 numbers on it like this?

function map_mid_to_cpt( $merchant_id ) {
$map = array(
8303 => 7903,
DF ID => POST ID,
DF ID => POST ID,
DF ID => POST ID,
DF ID => POST ID,
ETC ETC
);
return get_permalink( $map[$merchant_id] );
}

and put that in Function.php and then put the other piece of code in my view?

Will it matter that I have nearly 300 merchants?

Thanks,
Philip.

Eric June 17th, 2013 09:53 AM

Hi,

That's correct!

It won't matter for 300 merchants.

Eric

DohRayMi June 17th, 2013 10:49 AM

Hi,
I put the code into the functions.php file, with just 1 merchant to test it, but it messed up that part of the site, but now I can't get the functions.php file to save, it just goes to a blank page. I took the code out using FTP, and restored the file back to where it was just before I started, using a copy I had made, but I still can't save it.
My site is working OK.

Any idea what I did wrong?

I already have another Datafeedr function in there, although that didn't seem to matter earlier.

Being presumptious!, here's the entire code (it's a child theme)

<?php
################################# FIX IE 7 bugs #############################################
add_action( 'wp_head', 'ie_conditional' );
if (!function_exists('ie_conditional')) {
function ie_conditional()
{
echo "
<!--[if IE 7]>
<style>
#sidebar { margin-top:-16px;}
body.home #sidebar { margin-top:0px;}
#plusone-div {padding: 0 0 10px !important;}
#plusone-div {position:absolute;margin:12px 0 0 0 !important;display:inline;padding: 0 0 10px !important;}
</style>
<![endif]-->
<!--[if IE 8]>
<style>
#plusone-div {position:absolute;margin:12px 0 0 0 !important;display:inline;padding: 0 0 10px !important;}
</style>
<![endif]-->
";
}}
################################# END FIX FOR FACEBOOK LIKE THUMB URL ##########################################
function dfr_get_merchants() {
global $wpdb;
$merchants = $wpdb->get_results("SELECT merchant, merchant_id FROM ".$wpdb->prefix."dfr_shop_products GROUP BY merchant");
$html = '<option value="">Select a merchant</option>';
foreach ($merchants as $k => $v) {
if (trim($v->merchant) != "") {
$selected = (strip_tags($_GET['merchant_id'])==$v->merchant_id) ? ' selected="selected"' : '';
$html .= '<option value="'.$v->merchant_id.'"'.$selected.'>'.$v->merchant.'</option>';
}
}
return $html;
}
?>


Thank you so much if you can help, again.
Philip.

Eric June 17th, 2013 10:52 AM

Hi,

Try saving via your WP Admin editor: WordPress Admin Area > Appearance > Editor > functions.php

Eric

DohRayMi June 17th, 2013 11:58 AM

Sorry, that's where I was trying, the "Update File" button.
Just goes to a blank page called http://www.dohraymi.com/wp-admin/theme-editor.php
Philip.

Eric June 17th, 2013 12:14 PM

Hi,

Sounds like you have some file permission issues. You might need to get your web host to help you sort out those issues.

Eric

DohRayMi June 17th, 2013 12:52 PM

OK,
it's something to do with the functions file, I removed it and everythng is back to normal, apart from that file is missing of course haha.
I'll see what I can come up with.
Philip.

DohRayMi June 18th, 2013 08:21 AM

OK,
going great guns now, it works well!

Just 2 more related question please :)

Can I put the code you gave me within some button code, so the link appears inside a button, instead of just a text link? (if so, where please)

Can I reduce the height of the box around each product? I can see the CSS for the width, 33% in my case as it's 3 columns, but I can't see anythng for the height. There's a lot of white space.

Thanks again for your help.
Philip.

Eric June 18th, 2013 08:53 AM

Hi,

Yes, you simply need to do this:
HTML Code:

<a href="<?php echo map_mid_to_cpt( $product->merchant_id ); ?>" class="dfbutton dforange dflarge dfrounded">More info</a>
What page are you referring to regarding the height?

Eric

DohRayMi June 18th, 2013 09:04 AM

Thanks Eric,
it's on a test page at the minute - http://www.dohraymi dot com/city/portadown/local-vouchers/advertising-trailers
Regards,
Philip.

Eric June 18th, 2013 09:08 AM

Hi,

You need to add this to your Custom CSS:

#view .pl .col3 .thmb { height: 30px; }

Eric


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

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