Search
Other Articles Anywhere questions
Forum

if month..

INFINI Marketing's Avatar INFINI Marketing
we have want to show a unique article for each month.. jan, feb, mar, ... dec, all 12 months of the year.

how can we check, if it's "January" , then show this article..
if it's "February" , then show this article..
etc..

i just can't figure out how and where the "month" would be set, and where it is checked, in the if statement?
INFINI Marketing's Avatar INFINI Marketing
i've tried now to use with sourcerer, but its just echoing out the article string, not the article.. "{article id="10"}[text]{/article}" - how do you call the article?
{source}
[[?php
$currentMonth = date('n');
if ($currentMonth == 1) {
    echo '{article id="10"}[text]{/article}';
}
?]]
{/source}
Peter van Westen's Avatar Peter van Westen ADMIN
It is probably due to the system plugin ordering. Try changing the ordering of the plugins in question.
See: regularlabs.com/blog/242-plugin-order-is-important
Please post a rating at the Joomla! Extensions Directory
INFINI Marketing's Avatar INFINI Marketing
nice! this worked!, this also fixed the issue where I had to use the square brackets [[?php instead of the standard <?php
Peter van Westen's Avatar Peter van Westen ADMIN
{source}<?php
$monthArticles = [
    'January'   => 10,
    'February'  => 11,
    'March'     => 12,
    'April'     => 13,
    'May'       => 14,
    'June'      => 15,
    'July'      => 16,
    'August'    => 17,
    'September' => 18,
    'October'   => 19,
    'November'  => 20,
    'December'  => 21,
];
$currentMonth = date('F');

if(isset($monthArticles[$currentMonth])) {
    echo '{article id="' . $monthArticles[$currentMonth] . '"}[text]{/article}';
}
?>{/source}
Please post a rating at the Joomla! Extensions Directory
INFINI Marketing's Avatar INFINI Marketing
thanks for the code as well, i like your implementation much better!
i used a switch, always good to see how others complete the same task!
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription