test
Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • gray Friend
    #147713

    The issue is that “Last Update” data at the top differs from the date shown on the newest article.

    I’ve created an alternative getLastUpdate function to fix the issue (file ja.template.helper.php)

    [php]
    # Get time of last updated article Hacked by Gray
    function getLastUpdate(){
    $db = &JFactory::getDBO();
    $query = ‘SELECT created FROM #__content a ORDER BY created DESC LIMIT 1’;
    $db->setQuery($query);
    $data = $db->loadObject();

    if( $data->created ){
    $user =& JFactory::getUser();
    if ($user) {
    $offset = $user->getParam(‘timezone’);
    } else {
    $offset = NULL;
    }
    $format = ‘%d.%m.%Y %H:%M’;
    return JHTML::_(‘date’, $data->created, $format, $offset);
    } else {
    return ”; // emtpy string
    }
    }
    [/php]

    ithacaindy Friend
    #331058

    <em>@gray 160685 wrote:</em><blockquote>The issue is that “Last Update” data at the top differs from the date shown on the newest article.

    I’ve created an alternative getLastUpdate function to fix the issue (file ja.template.helper.php)

    </blockquote>

    Do I create this file – and where do I save it?

    gray Friend
    #331061

    This function already exists in file
    file templatesja_teline_iiilibsja.template.helper.php

    You should replace existing funtion with the new one (please keep back-ups of all files being modified!)

    ithacaindy Friend
    #331071

    There’s a problem with the alternative function; a missplaced } somewhere. I restored the original file.

    gray Friend
    #331125

    <em>@ithacaindy 162870 wrote:</em><blockquote>There’s a problem with the alternative function; a missplaced } somewhere. I restored the original file.</blockquote>

    This function works on my site, and it does not have problems with missing or additional “}”
    You should replace the entire function getLastUpdate with the new code.

    ithacaindy Friend
    #331227

    The new function doesn’t create any errors. However, the update time doesn’t match the last post’s time. Additionally, the time still says “GMT”; I’d like it to be my EST default, as set in global preferences.

    gray Friend
    #331267

    <em>@ithacaindy 163054 wrote:</em><blockquote>The new function doesn’t create any errors. However, the update time doesn’t match the last post’s time. Additionally, the time still says “GMT”; I’d like it to be my EST default, as set in global preferences.</blockquote>

    It uses Joomla’s function JHTML::_(‘date’, $data->created, $format, $offset) to return formatted date.

    If last post time doesn’t match, see if correct time zone is set in Global Configurations.
    As regards ‘GMT’ it should not appear, as $format = ‘%d.%m.%Y %H:%M’ has no “GMT” attached.

    ithacaindy Friend
    #331317

    The Global Configurations/Server/Locale Settings is set to UTC -05:00 (Eastern Time). The last update says “Last update: 09:00:01 AM GMT”.

    gray Friend
    #331358

    Very strage.. The new function has $format = ‘%d.%m.%Y %H:%M’ (that is Dya.Month.Year Hour:Minutes) and no “GMT” string.
    Have you replaced the old funtion getLastUpdate in ja.template.helper.php with the new one?

    hcardenas Friend
    #334068

    Thank you very much, Gray. it worked fine!!

    tgtff Friend
    #339480

    This new code worked well for me – the correct date and time are now showing.

    However what does have a problem with this format is when you schedule articles i.e. for the future. The last update actually appears as the future article date and time.

    Any ideas on how to fix that?

    many thanks

    gray Friend
    #339501

    To tgtff

    Time is selected by the code:
    [PHP] $query = ‘SELECT created FROM #__content a ORDER BY created DESC LIMIT 1’;[/PHP]

    Do you put “Created” date in future?

    jelgervisser Friend
    #353063

    Doesn’t work properly for me.

    Offset is set +1 (i.e. Amsterdam). But the function ignores this. Last update shows 13.40. Should be 14.40.

    I have replaced the whole old function. And the Global Configurations > Server > Locale Settings is set to UTC +01:00.

    Any ideas?

    Thanks, Jelger

    Saguaros Moderator
    #353127

    <em>@gray 160685 wrote:</em><blockquote>The issue is that “Last Update” data at the top differs from the date shown on the newest article.

    I’ve created an alternative getLastUpdate function to fix the issue (file ja.template.helper.php)

    [php]
    # Get time of last updated article Hacked by Gray
    function getLastUpdate(){
    $db = &JFactory::getDBO();
    $query = ‘SELECT created FROM #__content a ORDER BY created DESC LIMIT 1’;
    $db->setQuery($query);
    $data = $db->loadObject();

    if( $data->created ){
    $user =& JFactory::getUser();
    if ( $user ) {
    $offset = $user->getParam(‘timezone’);
    } else {
    $offset = NULL;
    }
    $format = ‘%d.%m.%Y %H:%M’;
    return JHTML::_(‘date’, $data->created, $format, $offset);
    } else {
    return ”; // emtpy string
    }
    }
    [/php]</blockquote>

    The above solution is to follow the user’s Timezone when user logins the site. I suggest some extra changes to follow both the System’s Time Zone and the user’s Timezone:
    a) change code:
    [PHP]

    function getLastUpdate(){
    $db = &JFactory::getDBO();
    $query = ‘SELECT created FROM #__content a ORDER BY created DESC LIMIT 1’;
    $db->setQuery($query);
    $data = $db->loadObject();

    if( $data->created ){
    $user =& JFactory::getUser();
    if ( $user->getParam(‘timezone’) ) {
    $offset = $user->getParam(‘timezone’);
    } else {
    $conf =& JFactory::getConfig();
    $offset = $conf->get(‘config.offset’);
    }
    $format = ‘%d.%m.%Y %H:%M’;
    return JHTML::_(‘date’, $data->created, $format, $offset);
    } else {
    return ”; // emtpy string
    }
    }
    [/PHP]

    b) update system ‘s TimeZone: Go to Administrator => Site => Global Configuration and choose tab Server and then update the Time Zone in Locale Settings

    gray Friend
    #353159

    tienhc, thanks for the updating!
    Could this hack be a part of Teline IV?

Viewing 15 posts - 1 through 15 (of 17 total)

This topic contains 17 replies, has 8 voices, and was last updated by  firon 14 years, 2 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum