Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

I have been using Joomla since 1.0 and I can tell that it is an awesome software. All the websites I do are done with Joomla. However, I have realized that Joomla is missing some options that may be very useful. In this case the capability to auto archive articles; this is very handful especially when you are writing a blog like mine.

In this article, I will show you all how to do this. I will assume you are familiar with your database and you have access to CLI.

 Do the following steps:

  1. Get your database details. All information is inside the configuration.php file of your Joomla installation. You will need:
    1. Database name,
    2. Database username,
    3. Database username password,
    4. Table prefix (it ends with a _).
  2. Define your auto-archive policy. In my case, I decide to archive all articles under my 'blog' category that haven't been modified (including creation) for more than a month.
  3. Go to the CLI and edit a file (put attention where you save it, usually /usr/local/bin is a good place). In my example, the file is called auto.archive.sh. Put this:
    #!/bin/sh
    /usr/bin/mysql -u MYSQL_USER -pMYSQL_PASSWORD DATABASE -e 'UPDATE #PREFIX_content content JOIN #PREFIX_categories category ON category.id=content.catid SET content.state = 2 WHERE DATEDIFF(CURDATE(),created) > 30 AND category.path LIKE "blog/%"'
  4. I will execute this script always at 00:00. So I added the following crontab:
    0 0 * * * /usr/local/bin/auto.archive.sh

Happy blogging!

blog comments powered by Disqus

About

Read about IT, Migration, Business, Money, Marketing and other subjects.

Some subjects: FusionPBX, FreeSWITCH, Linux, Security, Canada, Cryptocurrency, Trading.