Replace previous/next by images

About the template and stylesheet - and changing the menu
Post Reply
Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Replace previous/next by images

Post by Tata » Sat Apr 09, 2016 12:15 pm

How shall be coded the replacement of next/previous word/character by an image?
I have placed images into the template

Code: Select all

                <table width="100%" cellspacing="0" cellpadding="0" border="0">
                    <tr>
                        <td class="previous">
                            <?php echo tag('img src="'.$pth['folder']['templateimages'].'previous.png" alt="'.$tx['navigator']['previous'].'"');?>
                        </td>
                        <td class="top">
                            <a href="#TOP" title="<?php echo $tx['navigator']['top'];?>"><?php echo tag('img src="'.$pth['folder']['templateimages'].'top.png" alt="'.$tx['navigator']['top'].'"');?>
                        </td>
                        <td class="next">
                            <?php echo tag('img src="'.$pth['folder']['templateimages'].'next.png" alt="'.$tx['navigator']['next'].'"');?>
                        </td>
                    </tr>
                </table>
but the alt attribute doesn't work and I don't know how to link the image to next/previous function.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Replace previous/next by images

Post by cmb » Sat Apr 09, 2016 2:44 pm

Tata wrote:[…] the alt attribute doesn't work […]
That is supposed to work; you may need to escape special HTML characters, though:

Code: Select all

<?php echo tag('img src="'.$pth['folder']['templateimages'].'previous.png" alt="'.XH_hsc($tx['navigator']['previous']).'"');?>
Tata wrote:and I don't know how to link the image to next/previous function.
Indeed, that's somewhat a problem. Most likely it's best to make a copy of the functions previouspage() and nextpage() and place them directly in the template under another name; adjust these functions and call them instead of previouspage()/nextpage(). (Not ideal, but supposed to work.)

Code: Select all

function tpl_previouspage()
{
    global $tx;

    $index = XH_findPreviousPage();
    if ($index !== false) {
        return a($index, '" rel="prev" alt="' . $tx['navigator']['previous']) . tag('img src="userfiles/images/flags/de.gif"') . '</a>';
    }
}

function tpl_nextpage()
{
    global $tx;

    $index = XH_findNextPage();
    if ($index !== false) {
        return a($index, '" rel="next" alt="' . $tx['navigator']['next']) . tag('img src="userfiles/images/flags/de.gif"') . '</a>';
    }
} 
BTW: using the default supplied language texts as alt text is not correct, in my opinion, because the alt text is supposed to describe the image, but not its function. I would use the default texts as title, and add some descriptive text for the alt attribute.
Christoph M. Becker – Plugins for CMSimple_XH

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Replace previous/next by images

Post by Tata » Sat Apr 09, 2016 6:21 pm

THX, that's it. However, on 2lang it seems not to work. I tried to change the code by

Code: Select all

function tpl_previouspage()
{
    global $tx; $pth;

    $index = XH_findPreviousPage();
    if ($index !== false) {
        return a($index, '" rel="prev" alt="' . $tx['navigator']['previous']) . tag('img src="'.$pth['folder']['templateimages'].'previous.png" class="prev"') . '</a>';
    }
}

function tpl_nextpage()
{
    global $tx;

    $index = XH_findNextPage();
    if ($index !== false) {
        return a($index, '" rel="next" alt="' . $tx['navigator']['next']) . tag('img src="'.$pth['folder']['templateimages'].'next.png"') . '</a>';
    }
} 
But the previous, next icons are not loaded and in their properties is:
http://localhost:8888/website/previous.png
but there should be
http://localhost:8888/warhol/templates/ ... evious.png
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Replace previous/next by images

Post by Tata » Sun Apr 10, 2016 10:42 pm

Nun, am Localhost funtioniert es. AN einer Subdomain an meinem Hostserver, aber nicht. Es würde wohl relative URL brauchen, oder?
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Replace previous/next by images

Post by Tata » Wed Apr 13, 2016 4:18 am

Das habe ich gelösst. Diese Losung funktioniert aber nur für die Hauptsprache. Was soll da erweitert sein, um auch unter 2lang zu funtionieren?
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

lck
Posts: 2955
Joined: Wed Mar 23, 2011 11:43 am
Contact:

Re: Replace previous/next by images

Post by lck » Wed Apr 13, 2016 10:37 am

Scheint ja bereits behoben zu sein :?
„Bevor du den Pfeil der Wahrheit abschießt, tauche die Spitze in Honig!“   👉 Ludwig's XH-Templates for MultiPage & OnePage

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Replace previous/next by images

Post by Tata » Wed Apr 13, 2016 1:09 pm

Ja. SO funktioniert es auch unter 2lang pages:

Code: Select all

    function tpl_previouspage()
    {
        global $tx, $pth;

        if ($index !== false) {
            return a($index, '" rel="prev" alt="' . $tx['navigator']['previous']) . tag('img src="'.$pth['folder']['userfiles'].'images/previous.png"') . '</a>';
        }
    }

    function tpl_nextpage()
    {
        global $tx, $pth;

        $index = XH_findNextPage();
        if ($index !== false) {
            return a($index, '" rel="next" alt="' . $tx['navigator']['next']) . tag('img src="'.$pth['folder']['userfiles'].'images/next.png"') . '</a>';
        }
    }
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Replace previous/next by images

Post by Tata » Sun Apr 17, 2016 5:42 pm

Now, while testing the iconized prev/next function, I see that the "next" works fine. But the "prev" returns always to the very first page. What may be the reason?
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Replace previous/next by images

Post by Tata » Mon Apr 18, 2016 5:45 am

Turning the PC ON this morning, the "prev" icon works as expected 8-)
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Replace previous/next by images

Post by cmb » Mon Apr 18, 2016 5:49 pm

Tata wrote:Turning the PC ON this morning, the "prev" icon works as expected 8-)
Fine. :)

Maybe OPcache was involved here, also.
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply