Jump to content

If statement/link to the WHMCS marketplace connect pages


zomex

Recommended Posts

Hello there,

 

I'm wondering if anyone has a if statement & markup that can be used to link to the WHMCS marketplace connect pages (email, website builder, SSL certs).

 

This will be used within a WHMCS template only.

 

Thanks.

Link to comment
Share on other sites

an if statement in what sense - to see if the feature is enabled?

 

I know you can link to them directly using the following method...

 

index.php?rp=/store/email-service

index.php?rp=/store/ssl-certificates

index.php?rp=/store/website-builder

 

and depending on the friendly urls setting, i've seen /store/website-builder used too... though even with that enabled, index.php?rp=/store/website-builder still redirects to the correct page. :idea:

Link to comment
Share on other sites

an if statement in what sense - to see if the feature is enabled?

 

I know you can link to them directly using the following method...

 

index.php?rp=/store/email-service

index.php?rp=/store/ssl-certificates

index.php?rp=/store/website-builder

 

and depending on the friendly urls setting, i've seen /store/website-builder used too... though even with that enabled, index.php?rp=/store/website-builder still redirects to the correct page. :idea:

 

Yes that's correct Brian, a if statement if they are enabled.

 

Then a way to pull the URLs based on the users friendly URL settings.

 

Cheers

Link to comment
Share on other sites

Yes that's correct Brian, a if statement if they are enabled.

Then a way to pull the URLs based on the users friendly URL settings.

as I don't have MC enabled, I can't really help with the first... i'd be tempted to think there wouldn't be a Smarty variable to show whether any are enabled or not - though {debug} will be your friend there... I suppose you could query the primary navbar array and see if they're mentioned in there, but that may not be definitive.... there's also a marketconnect_services table, but i'm not sure what it would contain... if you find a way, let us know!

 

the Friendly URLS is slightly easier in the sense that it's value is stored in the configuration table (RouteUriPathMode) - and can therefore be accessed by an action hook... I doubt the value is passed to the Smarty template, so a hook might be the only viable way to know for certain.

 

Full Friendly -> rewrite

Friendly -> acceptpathinfo

Basic -> basic

 

you can then base your IF statement on those values and adjust the urls accordingly.

Link to comment
Share on other sites

as I don't have MC enabled, I can't really help with the first... i'd be tempted to think there wouldn't be a Smarty variable to show whether any are enabled or not - though {debug} will be your friend there... I suppose you could query the primary navbar array and see if they're mentioned in there, but that may not be definitive.... there's also a marketconnect_services table, but i'm not sure what it would contain... if you find a way, let us know!

 

the Friendly URLS is slightly easier in the sense that it's value is stored in the configuration table (RouteUriPathMode) - and can therefore be accessed by an action hook... I doubt the value is passed to the Smarty template, so a hook might be the only viable way to know for certain.

 

Full Friendly -> rewrite

Friendly -> acceptpathinfo

Basic -> basic

 

you can then base your IF statement on those values and adjust the urls accordingly.

 

 

Thanks Brian.

 

I haven't been able to get this working yet, I hope WHMCS in a new version will make variables available for this.

Link to comment
Share on other sites

I haven't been able to get this working yet, I hope WHMCS in a new version will make variables available for this.

so curiosity got the better of me on this, and I decided to take a closer look... I had to enable MarketConnect on the dev *shudders* - as an aside, having now seen it close up, I still wouldn't touch it with a bargepole. 43.gif

 

it turns out what I said previously was correct - tblmarketconnect_services is the source of the information you need - basically, if one of the marketconnect services is enabled in there, it's 'status' value will be '1', if it's not been enabled before, it won't exist in the table and if it's been enabled and later disabled, the value will be '0'... so armed with that, I can then do this...

<?php

# Create Market Connect Links for Zomex.
# Written by brian!

use Illuminate\Database\Capsule\Manager as Capsule;

function zomex_marketconnect_hook($vars)
{
   global $CONFIG;    
   $friendlyurl = $CONFIG['RouteUriPathMode'];

   if ($friendlyurl == 'acceptpathinfo') {
       $urlpath = 'index.php/store/';
   }
   elseif ($friendlyurl == 'rewrite') {
       $urlpath = 'store/';
   }
   elseif ($friendlyurl == 'basic') {
       $urlpath = 'index.php?rp=/store/';
   }

   $marketconnect = Capsule::table('tblmarketconnect_services')->where('status', '1')->get();

   if (count($marketconnect)) {

       foreach ($marketconnect as $service) {
           if ($service->name == 'spamexperts') {
               $spamexpertslink = $urlpath.'email-services';
           }
           elseif ($service->name == 'symantec') {
               $symanteclink = '<a href="'.$urlpath.'ssl-certificates">'.Lang::trans('navMarketConnectService.symantec').'</a>';
           }    
           if ($service->name == 'weebly') {
               $weeblylink = '<a class="btn-sm btn-warning" href="'.$urlpath.'website-builder'.'" target="_blank">'.Lang::trans('navMarketConnectService.weebly').'</a>';
           }
       }
       return array("spamexpertslink" => $spamexpertslink, "symanteclink" => $symanteclink, "weeblylink" => $weeblylink);
   }
}
add_hook("ClientAreaPage", 1, "zomex_marketconnect_hook");

with that, you'll get 3 new Smarty variables on every client page (including cart) in WHMCS - each containing a specific link for each service, formatted based on the current Friendly URLs value. :idea:

 

btw technically, you could possibly trim that foreach down by using variable variables, but I don't think you'd really gain anything in the short-term by doing that, and also the way i've done it as above, should be easier for others to follow.... long-term, it might be something worth me revisiting if WHMCS continue to add more services to the MarketConnect platform (though as I suspect the specific service URLs are hard-coded and not pulled from somewhere, that may be pointless)... anyway, you could easily expand the current IF statement to cover all eventualities as services are added/removed.

 

as you can see from the above code, these links are not all constructed in the same way - as I didn't know exactly what you intended to use them for, i've given you three flavours to work with as each service gives a slightly different output...

 

{$spamexpertslink} -> would just output the URL for spamexperts.

{$symanteclink} -> outputs a normal <a href> link for symantec ssl certs.

{$weeblylink} - outputs an orange bootstrap button that opens in a new window/tab for weebly website builder.

 

bxfFO1s.pngn8Hjli0.png

 

obviously, all 3 should use the same format - but i'll leave it to you to choose what you want to do with them! :)

 

a few other things to note...

 

1. if MarketConnect is not enabled (or if it is but all 3 services are deactivated), then the query will be empty and the 3 Smarty variables will not be created.

2. if a specific MC service is not activated (e.g SpamExperts), then the Smarty variable generated will exist, but it's value will be NULL... that allows you to do something along the lines of the code below to test in the template if the MC service (spam, symantec or weebly) is active...

{if $spamexperts}Spam Experts is active{else}it is not active{/if}

or if you only want to show a MC link if the specific service is available..

{if $weeblylink}{$weeblylink}{/if}

btw - if it's used in your commercial templates, i'll look forward to receiving my share of your vastly increased sales! :-P

 

and with that, i'll be gone for the next few days as i'm having a belated birthday mini break (yes just as the heatwave ends!) - as far away from the internet, and MarketConnect, as humanly possible. :)

Link to comment
Share on other sites

Wow Brian I would like to thank you greatly for the time you put into helping me and the rest of the community out. Not just with this script but your overall passion and dedication to WHMCS and helping other users.

 

I've implemented your script with just a few modifications and it's working perfectly:

 

marketplace1.jpg

marketplace2.png

 

----------

 

Do you have a way I can donate money to you such as via PayPal?

 

Or better yet if you PM me your address or PO box I would like to send you a gift as thanks for your help.

 

PS: Enjoy your holiday!

 

Thanks once again.

Link to comment
Share on other sites

  • 2 months later...
After enabling Marketplace nav-menu(Website & Security) had become dummy when a 3rd party WHMCS Theme is used how to integrate it. It works fine in inbuilt themes like "5" & "6". Help me

ADC is correct on this... if you're even mentioning 5 and 6, then it sounds as though it's an old theme that you're using... if there's an updated version available by the developer, use that - otherwise, you're looking at either employing a WHMCS integration expert to fix the theme for compatibility with current and future releases, or just abandoning the current template and moving on to a new theme compatible with the version of WHMCS you have.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated