Jump to content

brian!

GearHead
  • Content count

    10,061
  • Joined

  • Last visited

  • Days Won

    267

Everything posted by brian!

  1. I read everything (I think!)... they're just telling the hook to get ready, we're about to query/update the database... mine is probably from how the example hooks were posted when v6 came out; steven's is how they're posted now... they're both doing the same thing and at this stage, I wouldn't worry about it too much - when i'm writing a new hook, i'm using one of a number of hook templates and it will likely contain that line that i've always used... and I don't know if that new method would only work on v7.... so when I get the chance, i'll have a play and see, but don't worry about it for now - as long as the hook can find Capsule, then the queries will work. they're fine and are just incremental counter, e.g., $x++ just adds 1 to the value of $x... steven99 was using a loop with a value but no key; whereas in mine, i'm specifying to use both the value and the key, and subsequently don't need to use a separate counter variable.
  2. i'm still inclined to think so. there are none - but a lot of WHMCS is probably still how it was 10 years ago, and this may be one of those occasions. but if the database doesn't store the updated date (or any date), then you're into the realms of having to store the date yourself when you update/create an article in the admin area... but I don't think that there are any specific hook points triggered when editing an article, so no simple way to do this. you can't extract what hasn't been saved. πŸ™‚ no - just what has been programmed to be returned to be available to the template. not necessarily - as you saw with the useful/votes hook that I wrote that just amended the array with new content and returned it to the template... if the dates were naturally in the table, you could use that hook for this, but there are no dates stored. i'm not saying that it couldn't ultimately be done, just that there isn't a quick "here's a hook" solution... it's likely going to need an addon module for this, probably with custom database tables too.
  3. one option is a quick fix with css... .grecaptcha-badge { left: 0px; } and technically, you could hide it with the css code below (it still validates), but that would almost certainly be against Googles T&Cs... .grecaptcha-badge { visibility: hidden; } the real solution is probably going to involve using the "data-badge" feature - which by default is bottomright, but you can define it to be bottomleft - I can do it by editing scripts.js and changing.... // propagate invisible recaptcha if necessary if (isInvisible) { if (recaptchaContent.data('size') !== 'invisible') { recaptchaContent.attr('data-size', 'invisible'); } } else { recaptchaContent.hide() } to... // propagate invisible recaptcha if necessary if (isInvisible) { if (recaptchaContent.data('size') !== 'invisible') { recaptchaContent.attr('data-size', 'invisible'); recaptchaContent.attr('data-badge', 'bottomleft'); } } else { recaptchaContent.hide() } ... minifying it and saving as scripts.min.js now someone, perhaps one of WHMCS' own devs, who is better than me at JavaScript, should be able to make that into a hook.... long-term, there's nothing to stop WHMCS putting a left/right location dropdown toggle in the security tab, but that's heading down the road of a feature request, so it won't be happening any time soon. πŸ™„ in fact, they should have already made it multilingual - as I showed how in the thread below.... though everything seems to be defined in the .js files now, so I doubt quick template edits wouldn't work on the latest versions.
  4. yes - similar hook, you just have to change the array used and the hook point called... <?php # Remove Cancelled Domains From Array Hook # Written by brianο»Ώ! function clients_domains_hide_cancelled_hook($vars) { $hideStatus = array ('Cancelled'); $domains = $vars['domains']; foreach($domains as $key => $domain) { if (in_array($domain['status'], $hideStatus)) { unset($domains[$key]); } } return array("domains" => $domains); } add_hook("ClientAreaPageDomains", 1, "clients_domains_hide_cancelled_hook"); and then to hide the cancelled filter, you could remove it with another hook or hide it with css.. #Primary_Sidebar-My_Domains_Status_Filter-clientareacancelled {display: none;}
  5. brian!

    Save cart for later

    perhaps a better solution for your situation will be Share Cart...
  6. brian!

    Adding Cookie Control to Client Pages

    yes... occasionally, I think you might need to output in the header instead of the footer (depending on what you're trying to do), but the Google Analytics addon uses a ClientAreaFooterOutput in the same way as your hook.
  7. brian!

    Adding Cookie Control to Client Pages

    answers on a postcard, please! πŸ˜› upload the attached file to /includes/hooks (or create a new .php file in there and copy&paste the above code) and the next time you refresh your site in the browser, you should see the cookie bar... πŸ™‚ thisimattcookie.php
  8. brian!

    Hide Menu Items before user login

    lol - it only occurred to me this morning when I realised it had it's own css ID. πŸ™‚
  9. brian!

    Adding Cookie Control to Client Pages

    the following hook should work for you @thisismatt... <?php # Matt's Cookie Hook # Written by brian! function thisismatt_cookie_hook($vars) { return <<<HTML <!-- Cookie Consent by https://TermsFeed.com --> <script type="text/javascript" src="//termsfeed.com/cookie-consent/releases/3.0.0/cookie-consent.js"></script> <script type="text/javascript"> document.addEventListener('DOMContentLoaded', function () { cookieconsent.run({"notice_banner_type":"headline","consent_type":"express","palette":"dark","change_preferences_selector":"#changePreferences","language":"en"}); }); </script> <noscript><a href="https://termsfeed.com/cookie-consent/">Cookie Consent by TermsFeed</a></noscript> <!-- End Cookie Consent --> HTML; } add_hook("ClientAreaFooterOutput", 1, "thisismatt_cookie_hook");
  10. the following hook will minimise the tag cloud sidebar... <?php # Minimise Tag Cloud Sidebar Hook # Written by brian! function minimise_tag_cloud_sidebar_hook($vars) { $kbpages = ['knowledgebase','knowledgebasecat','knowledgebasearticle']; $templatefile = $vars['templatefile']; if (in_array($templatefile,$kbpages)) { return <<<HTML <script> jQuery(function(){ jQuery('div[menuItemName="Support Knowledgebase Tag Cloud"]').find('i[class~="fa-chevron-up"]').click(); }); </script> HTML; } } add_hook("ClientAreaFooterOutput", 1, "minimise_tag_cloud_sidebar_hook"); ?> if it doesn't work for you, then you may need to declare the array using the old-fashioned method... $kbpages = array('knowledgebase','knowledgebasecat','knowledgebasearticle'); ... or don't use in_array and just use an "or" to check for the $templatename values in the ID statement.
  11. i'd suggest writing the hook as below - it's a little redundant to use two separate database queries and foreach loops, so i've merged them into just one... <?php # Add Votes & Useful Values To kbarticles Array Hook # Written by brian! use Illuminate\Database\Capsule\Manager as Capsule; function kbarticles_add_votes_and_useful_fields_hook($vars) { if ($vars['templatefile'] == 'knowledgebasecat') { $kbarticles = $vars['kbarticles']; foreach($kbarticles as $key => $article) { $results = Capsule::table('tblknowledgebase')->where('id',$article['id'])->select('votes','useful')->first(); $kbarticles[$key]['votes'] = $results->votes; $kbarticles[$key]['useful'] = $results->useful; } return array("kbarticles" => $kbarticles); } } add_hook("ClientAreaPageKnowledgebase", 1, "kbarticles_add_votes_and_useful_fields_hook"); ?> this will still give you the $kbarticle.votes} and {$kbarticle.useful} values that you can output in your template.
  12. brian!

    Set Custom Link order On SSL

    this does work, but for me it needed the full URL to cart.php for it to do so.
  13. i'd glad that you got this resolved!
  14. brian!

    Translate Tax ID field

    also, don't edit the original language files, just use Language Overrides to create the modified strings - otherwise your changes will be lost after an update. although it isn't specifically mentioned in the documentation, you can use overrides in the same way on the admin language files too.
  15. brian!

    Hide Menu Items before user login

    the "client area" is basically everything that a user can see from their front-end... they may be a client, or just a new visitor to your site and it includes the opening pages, the cart and all the client-only pages that can be seen when a user logs in. the action hook equivalent of what @pRieStaKos suggests with his template edit, would be to hide by navbar using css if the user is not logged in... <?php # Hide Navbar If User Not Logged In Hook # Written by brian! function hide_navbar_hook($vars) { $client = Menu::context('client'); if (!$client) { $csscode = "<style>#main-menu { display: none; }</style>"; return $csscode; } } add_hook("ClientAreaFooterOutput", 1, "hide_navbar_hook"); or using JavaScript... <?php # Hide Navbar If User Not Logged In Hook # Written by brian! function hide_navbar_hook($vars) { $client = Menu::context('client'); if (!$client) { $csscode = "<script> $(function() { $('#main-menu').remove();ο»Ώ }); </script>"; return $csscode; } } add_hook("ClientAreaFooterOutput", 1, "hide_navbar_hook"); if you just want to change the text, then you can use the Language Overrides feature and modify the strings for each language that you wish to change.
  16. you might need to compare the differences between standard_cart/checkout.tpl with your own checkout.tpl template - but chances are that it will involve more than just template changes, and will require the use of .js files that may or may not be present in your custom template... if that's the case, you may need to pay a developer to sort this out for you.
  17. brian!

    Contact Us Page creating tickets twice

    you could try disabling captcha to see if that helps, but you might be better off opening a ticket with Support.
  18. brian!

    productGroup.name

    try the following as a starting point... <ul class="nav nav-tabs" data-toggle="tabs"> {foreach $productgroups as $productgroup} <li><a href="cart.php?gid={$productgroup.gid}">{$productgroup.name}</a></li> {/foreach} </ul> ... obviously would only working if the template you're editing has access to the $productgroups array - if it doesn't, then you would need a hook to create it.
  19. brian!

    Turn off "Hide Inactive Clients" for good?

    i'd be interested to hear too! though editing the menu.tpl template would work as well and removes any potential redirection issues (not that I think there are any with the hook).
  20. and also it's potentially a very dodgy thing to do... I buy a domain from your site, assume that it's going to be registered with my email address... then find out that it isn't, it's been registered to your email address and thus I cannot transfer or sell it.
  21. brian!

    Set Custom Link order On SSL

    not specifically, but this occurs on the products main page, not on the details page - so that hook may not be relevant. for the details pages, I posted the hook in the thread below that nuked the array, thus solving the output problem there... in any event, I found two working solutions to this and felt that was enough for now as who knows if WHMCS are minutes/days/weeks/months away from solving this themselves! plus to be honest, coding js is not something I enjoy doing, so I avoid if whenever I can! πŸ™‚
  22. brian!

    See using a different div on pages.

    what happens if you try the following...? <div class="container-fluid relative animatedParent animateOnce {if $templatefile eq 'viewticket'}p-0{else}my-3{/if}">
  23. brian!

    Save cart for later

    there is an Abandoned Cart addon in Marketplace, but it's not getting great reviews... nor do I think it's been updated for recent versions...
  24. I suggest you have a serious word with your host as to why the feature isn't working... as you say, it should be... and that above screenshot was from a v7.7 running on 5.6 given the alternative of having to go around the houses with multiple lines of code that you should be able to do with one, i'd put more effort into working this issue out with your host. i'm tempted to say wrap it in {php} tags and see if that works... but if you think the answer is to use {php} in a smarty template like that, then you're asking the wrong question... it's not a good idea. what I would do would be to use a hook - take the domains array, loop though it, run your php function on the domain value, create a new idn domain value, return the array back to the template... and then in the template, you should have a new variable you can add to the template... but having said all that, I really would suggest contacting your host as to why idn_to_utf8 isn't working (perhaps it needs installing or enabling by them)... solving that would be far simpler than writing that hook!
  25. @WHMCS John, i'm not sure what @bear has to do with this thread! πŸ™‚ just to be sure - are you saying that what i'm seeing in my devs is a bug (e.g using Boxes for error.tpl), and not a quirk of my devs ?
×

Important Information

By using this site, you agree to our Terms of Use & Guidelines