Jump to content
cdeese8

knowledgebase article date - is there an available hook yet?

Recommended Posts

Might you know if this is still the best way to do it @brian!? Just manually add date to the actual KB Article in WHMCS admin? I logged into Adminer and checked the DB and didn't any relevant tables for "last updated" in the knowledgebase tables.

I would have replied to community thread but I think it's locked / archived.

I was hoping to be able to automate things a bit more and make it so, when a person clicks Yes or No for the {$kbarticle.useful} {$LANG.knowledgebaseratingtext} strings in knowledgebasearticle.tpl file the site would display an updated "Last Updated" date string. Even a static last updated string would be cool if it was being tracked each time the actual article was being updated by an admin in the WHMCS side of things.

But yea, was just wondering if the date can be extracted? Does the the {debug} display all available things able to used from the WHMCS database? It's usually my goto thing and if something isn't in that popup window, it has to be done with an addon / module.

I'm gonna browse over the docs right now and see what I can dig up.

 

Edited by cdeese8
forgot links

Share this post


Link to post
Share on other sites
18 hours ago, cdeese8 said:

Might you know if this is still the best way to do it @brian!? Just manually add date to the actual KB Article in WHMCS admin?

i'm still inclined to think so.

18 hours ago, cdeese8 said:

I logged into Adminer and checked the DB and didn't any relevant tables for "last updated" in the knowledgebase tables.

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.

18 hours ago, cdeese8 said:

I was hoping to be able to automate things a bit more and make it so, when a person clicks Yes or No for the {$kbarticle.useful} {$LANG.knowledgebaseratingtext} strings in knowledgebasearticle.tpl file the site would display an updated "Last Updated" date string. Even a static last updated string would be cool if it was being tracked each time the actual article was being updated by an admin in the WHMCS side of things.

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.

18 hours ago, cdeese8 said:

But yea, was just wondering if the date can be extracted?

you can't extract what hasn't been saved. 🙂

18 hours ago, cdeese8 said:

Does the the {debug} display all available things able to used from the WHMCS database?

no - just what has been programmed to be returned to be available to the template.

18 hours ago, cdeese8 said:

It's usually my goto thing and if something isn't in that popup window, it has to be done with an addon / module.

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.

  • Thanks 1
  • Party/Celebrate 1

Share this post


Link to post
Share on other sites

Thanks for the one of most detailed replies one could ask for. All sorts of valuable info in here that adds more questions and answers a bunch. I feel like the only reason you must know what you know.. all the hidden stuff, is because you either helped write WHMCS or just have been using WHMCS for that many years. I mean, sometimes, I'm blown away by how much invisible * you know.. it's just insane.

For example, How do you know what's been saved to the DB is {debug} doesn't display it? Is it just a matter of looking at the DB tables and search & find?

Thanks for your wisdom.

 

Share this post


Link to post
Share on other sites
1 minute ago, cdeese8 said:

Thanks for the one of most detailed replies one could ask for. All sorts of valuable info in here that adds more questions and answers a bunch.

oh no - it shouldn't have led to more questions! lol

2 minutes ago, cdeese8 said:

I feel like the only reason you must know what you know.. all the hidden stuff, is because you either helped write WHMCS

i've just instructed my lawyers to begin proceedings for libel against you - I strenuously deny having any part in writing the WHMCS core program! naughty.gif🙂

as I posted earlier, WHMCS seemingly don't even have a spellchecker! celestial5.gif

recommended.jpg.3b088580dc4c42e37c9d98a1

7 minutes ago, cdeese8 said:

or just have been using WHMCS for that many years. I mean, sometimes, I'm blown away by how much invisible * you know.. it's just insane. 

the thing about using WHMCS is that the documentation is so limited, that if you want to do anything worthwhile with it, you really have to get your hands dirty and start playing with the code... and that's increasingly becoming more the case as recent versions are more dependant upon hooks than previous versions - I mean who in their right mind creates a software package where you need to use PHP to alter the menus and sidebars... it's insane... fine, I can do it... but a new user has no chance without reading the documentation... and even then... 🙄

i'm pretty sure before I got my license 2013 (21st March to be exact - 6th year anniversary coming up... jeez six years of banging my head against the brick wall of WHMCS!), I had never played with Smarty - but it's so flexible (especially as it can use PHP) that i'm always reluctant to abandon it to write a hook, but sometimes it's necessary.

the trick with WHMCS is when you find that doing x works with one aspect of WHMCS, it probably works with others - so it's just a case of trying to apply the correct solution to a given situation.

and there are many people that know more about WHMCS than I do - they just choose not to share that knowledge. 😞

e.g., the WHMCS internal developers will know lots more because a) they're writing the code (not me!) and b) they have access to the decrypted code... which I don't.

30 minutes ago, cdeese8 said:

For example, How do you know what's been saved to the DB is {debug} doesn't display it? Is it just a matter of looking at the DB tables and search & find?

in this instance, it was just a case of double-checking the knowledgebase database tables and seeing that there are no date fields in the structure...

  • Party/Celebrate 1

Share this post


Link to post
Share on other sites

You know, someone like you should be hired at $50 an hour to re-write some of the help / doc articles. I suspect, WHMCS could set-aside a $4,000 budget to invest into your organization and it would pay mega dividends.

The spell check thing? jeeze. I mean, mistakes happen but 9 months? Dang... 6 years is no joke. You are a great customer and community role-model.

How do you think sentq compares to you? If you guys duked it out on WHCMS wisdom test, you think he would wreck you? If you had access to the actual code, you think you could learn twice as much? Would you even want to learn more? Like that stuff is fun for you?

Cheers

p.s. - tell your friggin' lawyers to back off!

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)

Back to the topic, there's a lazy way to get "last updated". Be advised that it's not stylish but it works. When you edit an article WHMCS logs the event in the Activity Log. You can retreive the date you need from this table like follows.

<?php

use WHMCS\Database\Capsule;

add_hook('ClientAreaPageKnowledgebase', 1, function($vars)
{
	if ($vars['kbarticle']['id'])
	{
		$LastUpdated = Capsule::table('tblactivitylog')->where('description', 'like', 'Modified Knowledgebase Article ID: %' . $vars['kbarticle']['id'])->orderby('id', 'desc')->first(['date'])->date;
		$output['kbarticle'] = $vars['kbarticle'];
		$output['kbarticle']['lastupdated']['date'] = date('Y-m-d', strtotime($LastUpdated));
		$output['kbarticle']['lastupdated']['time'] = date('H:i:s', strtotime($LastUpdated));

		return $output;
	}
});

Here is what you get you are viewing the article.

imblue.PNG.e24736280a075900a23a312befee6f29.PNG

Edit your knowledgebasearticle.tpl and place {$kbarticle.lastupdated.date} and {$kbarticle.lastupdated.time} where you prefer. Keep in mind that it works also for newly added articles. The only problem it is susceptible to Prune Client Activity Logs feature but personally I've never saw people flushing this table.

Edited by Kian
  • Like 1

Share this post


Link to post
Share on other sites
On 4/14/2019 at 9:57 PM, Kian said:

Back to the topic, there's a lazy way to get "last updated". Be advised that it's not stylish but it works. When you edit an article WHMCS logs the event in the Activity Log. You can retreive the date you need from this table like follows.


<?php

use WHMCS\Database\Capsule;

add_hook('ClientAreaPageKnowledgebase', 1, function($vars)
{
	if ($vars['kbarticle']['id'])
	{
		$LastUpdated = Capsule::table('tblactivitylog')->where('description', 'like', 'Modified Knowledgebase Article ID: %' . $vars['kbarticle']['id'])->orderby('id', 'desc')->first(['date'])->date;
		$output['kbarticle'] = $vars['kbarticle'];
		$output['kbarticle']['lastupdated']['date'] = date('Y-m-d', strtotime($LastUpdated));
		$output['kbarticle']['lastupdated']['time'] = date('H:i:s', strtotime($LastUpdated));

		return $output;
	}
});

Here is what you get you are viewing the article.

imblue.PNG.e24736280a075900a23a312befee6f29.PNG

Edit your knowledgebasearticle.tpl and place {$kbarticle.lastupdated.date} and {$kbarticle.lastupdated.time} where you prefer. Keep in mind that it works also for newly added articles. The only problem it is susceptible to Prune Client Activity Logs feature but personally I've never saw people flushing this table.

Thanks Kian. This is so cool. What I was looking for!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By sokalsondha
      Hello community...
      I came back again. Can someone help me with my system.
      What happened is..
      We sell yearly service. Let's say client bought service 01/04/2018
      And his next due date is 31/03/2019.
      Now system generate invoice on 15/03/209
       
      But he didn't paid.
      He decide to pay on may..
      I knw the service will be suspended. But it's not a problem.
      Now if he pay on may .. I see his next due date will be 31/03/2020 not 01/05/2020
       
      So he is loosing a month when he didn't used the service in April.
      Can we have a hook to update the next invoice date the customer paid+365 days? 
      Please help me
       
    • By Web Host Pro
      Most addons have a capital letter under the billing date line but the super speed addon is not capitalized.
      How can I change this so they are all capitalized or all lower case.
       
       

    • By MaikelVE
      Hi!
      On the announcements WHMCS uses the English version of the dates like “Dec 25th”
      But in Dutch we say “25 december” not with a short version and the numers are in the first place.
      Anyone know a hook or a fix or maybe @WHMCS John a fix for the Dutch people?
    • By didier1
      Hello, I'm trying to build an email template that will use a custom field date that  is  already created with this format  (DD/MM/YY) and will add 1 day or 1 month depending of our needs as follow.
      We are working on something like that but need help for the syntax 
      {$service_custom_fields.0 + 1 } 
      ( will give 31 on a custom field value of 30/06/2018 - we are expecting 01/07/2018
      Do we need to convert that value into number and than add +1 than reconverting ? 
      many thanks again guys
       
       
    • By tolu
      Hi.
      I´m trying to develope a custom payment gateway and I need to create a form and post forward.
      My problem is that I need to somehow get fate into system in YYYYMMDD.
      In my gateways interface description I need to get this info for DELIVERY_DATE
       
      Here is a copy of the desc.
      "Delivery date. The best estimate of the date of delivery of the goods. If the exact delivery date is not
      known; using the latest possible date of delivery. Charges will be sent to the buyer with a credit facility
      delivery date."
       
      I found that from settings I can set up YYYY-MM-DD but how can it be modified?
       
      Please someone help me how to get my php code working.
  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

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