separate input from two attributes in /lang separate input from two attributes in /lang
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

separate input from two attributes in /lang

Started by Hanna., November 08, 2018, 01:49:21 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Hanna.

Hi all! I am looking to separate these two lines located in the language files by overwriting them in my theme.php:


$lang_list_albums['n_pictures'] = '%s files';
$lang_list_albums['last_added'] = ', last one added ';


I am designing my own themes, and I like to have an element with only "% files". The second line can be added under this one below instead, or not at all. (Not important to me)

$lang_list_albums['alb_hits'] = 'Album viewed %s times';

I know the recommendation is not to touch any of these files. Therefore I am hoping someone can help me put together a piece for the theme.php that overwrites this segment for me. It is very important to show amount of photos in each album, but not as important to say when last one was added.

Thank you in advance.

ron4mac

Copy this section from include/theme.inc.php at about line 4398:
/******************************************************************************
** Section <<<theme_album_info>>> - START
******************************************************************************/
// Format information which is displayed next to each album
function theme_album_info($pic_count, $link_pic_count, $last_upload_date)
{
    global $CONFIG, $lang_list_albums;

    if ($CONFIG['link_last_upload']) {
        $album_info = sprintf($lang_list_albums['n_pictures'], $pic_count) . (($CONFIG['link_pic_count'] && $link_pic_count > 0 ) ? sprintf(", {$lang_list_albums['n_link_pictures']}, {$lang_list_albums['total_pictures']}", $link_pic_count, $pic_count + $link_pic_count) : "") . (($pic_count || ($CONFIG['link_pic_count'] && $link_pic_count > 0 )) ? sprintf($lang_list_albums['last_added'], $last_upload_date) : "");
    } else {
        $album_info = sprintf($lang_list_albums['n_pictures'], $pic_count) . ($pic_count ? sprintf($lang_list_albums['last_added'], $last_upload_date) : "") . (($CONFIG['link_pic_count'] && $link_pic_count > 0) ? sprintf(", {$lang_list_albums['n_link_pictures']}, {$lang_list_albums['total_pictures']}", $link_pic_count, $pic_count + $link_pic_count) : "");
    }

    return $album_info;
}
/******************************************************************************
** Section <<<theme_album_info>>> - END
******************************************************************************/


and place it in your theme's theme.php file. Then modify as needed.

Hanna.

I tried this:

if (!function_exists('theme_album_info')) { //{THEMES}
/******************************************************************************
** Section <<<theme_album_info>>> - START
******************************************************************************/
// Format information which is displayed next to each album
function theme_album_info($pic_count, $link_pic_count, $last_upload_date)
{
    global $CONFIG, $lang_list_albums;

    if ($CONFIG['link_last_upload']) {
        $album_info = sprintf($lang_list_albums['n_pictures'], $pic_count) . (($CONFIG['link_pic_count'] && $link_pic_count > 0 ) ? sprintf(", {$lang_list_albums['n_link_pictures']}, {$lang_list_albums['total_pictures']}", $link_pic_count, $pic_count + $link_pic_count) : "") . (($pic_count || ($CONFIG['link_pic_count'] && $link_pic_count > 0 )) ? sprintf($lang_list_albums) : "");
    } else {
        $album_info = sprintf($lang_list_albums['n_pictures'], $pic_count) . ($pic_count ? sprintf($lang_list_albums) : "") . (($CONFIG['link_pic_count'] && $link_pic_count > 0) ? sprintf(", {$lang_list_albums['n_link_pictures']}, {$lang_list_albums['total_pictures']}", $link_pic_count, $pic_count + $link_pic_count) : "");
    }

    return $album_info;
}
/******************************************************************************
** Section <<<theme_album_info>>> - END
******************************************************************************/
} //{THEMES}
//EOF


Am I missing something? I erased the last added stuff in there.

ron4mac

You added 1 too many lines at the top and the bottom. Look carefully at what I had marked for you to copy.
The lines with all the asterisks are not necessary but help with demarcation.

Hanna.

Quote from: ron4mac on November 08, 2018, 05:11:42 AM
You added 1 too many lines at the top and the bottom. Look carefully at what I had marked for you to copy.
The lines with all the asterisks are not necessary but help with demarcation.

Yes I added all that, and I tried without it. No reaction still. It still picks up the $lang part about last added.

ron4mac

You can't just add it as-is ... you need to make the modifications that you want.

Put this in there:
/******************************************************************************
** Section <<<theme_album_info>>> - START
******************************************************************************/
// Format information which is displayed next to each album
function theme_album_info($pic_count, $link_pic_count, $last_upload_date)
{
    global $CONFIG, $lang_list_albums;

    $lang_list_albums['n_pictures'] = '%s files';      // <<=====

       $album_info = sprintf($lang_list_albums['n_pictures'], $pic_count) . (($CONFIG['link_pic_count'] && $link_pic_count > 0 ) ? sprintf(", {$lang_list_albums['n_link_pictures']}, {$lang_list_albums['total_pictures']}", $link_pic_count, $pic_count + $link_pic_count) : "");

    return $album_info;
}
/******************************************************************************
** Section <<<theme_album_info>>> - END
******************************************************************************/

Hanna.

Quote from: ron4mac on November 08, 2018, 02:05:53 PM
You can't just add it as-is ... you need to make the modifications that you want.

Put this in there:
/******************************************************************************
** Section <<<theme_album_info>>> - START
******************************************************************************/
// Format information which is displayed next to each album
function theme_album_info($pic_count, $link_pic_count, $last_upload_date)
{
    global $CONFIG, $lang_list_albums;

    $lang_list_albums['n_pictures'] = '%s files';      // <<=====

       $album_info = sprintf($lang_list_albums['n_pictures'], $pic_count) . (($CONFIG['link_pic_count'] && $link_pic_count > 0 ) ? sprintf(", {$lang_list_albums['n_link_pictures']}, {$lang_list_albums['total_pictures']}", $link_pic_count, $pic_count + $link_pic_count) : "");

    return $album_info;
}
/******************************************************************************
** Section <<<theme_album_info>>> - END
******************************************************************************/


Yes, but adding this results now in blank page...

Hanna.

Attaching the theme file.

ron4mac

It fails because that function is already in your theme.php (at line 420).  Remove that one ... or change it there, then remove the bottom one.

P.S. If you're going to override theme functions in your theme.php, don't include with the section the lines marked with //{THEMES} at the start and end of the section.

Hanna.

I came back to look at this solution. I've been using the pic count alone since we discussed this last.

However, the topic was started to separate the two of these officially by giving the last-updated another {} as supposed to pic count - how would that look like?

I'm looking to move the last updated by itself above album title, so I need it by itself.