Jump to content

knowledgebase article date - is there an available hook yet?


cdeese8

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
Link to comment
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.

Link to comment
Share on other sites

  • 2 weeks later...

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.

 

Link to comment
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...

Link to comment
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!

Link to comment
Share on other sites

  • 1 month later...

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
Link to comment
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!

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.

×
×
  • 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