• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

How to add forum icons in tabs added with listeners

SchmitzIT

Well-known member
#1
After asking the question above in a different thread, I suddenly got an idea, and wanted to test today if I could get it to work. I did, and so I figured I'd share how to accomplish this.

In our existing forum (www.entropiaplanets.com/forums (vB *ptooey* warning)) we use icons on our navigation tabs. We wanted to have the same thing in xF, and implementing this in the default tabs was easy, but the dynamically added tabs posed a wee bit more of a challenge.
Luckily, it is still fairly easy to accomplish, thoug, and here is how.

First off, find the template navigation. In it, look for lines 75 and 159:

Code:
                <a href="{$extraTab.href}" class="navLink">{$extraTab.title}</a>
Replace both cases with:

Code:
                <xen:if is="{$extraTab.image}">
                    <a href="{$extraTab.href}" class="navLink"><img src="{$extraTab.image}" width="24px" height="24px" border="0" alt="{$extraTab.title}" align="top" />&nbsp;&nbsp;{$extraTab.title}</a>
                <xen:else />
                    <a href="{$extraTab.href}" class="navLink">{$extraTab.title}</a>
                </xen:if>
In a nutshell, this adds an image, the source of which is a new variable called $extraTab.image, and with a size of 24*24 pixels, no borders, and an alt tag the same as the title.

The last step to take is then to go to the installation folder of the add-on for which you want to add the icon to (I personally use Jaxels XenMedio and XenAtendo, as well as the excellent Leafnet Blog from Onimua), and make a minor alteration there.

I'll use the LeafNet blog as an example. The add-on will typically install in the folder <xf-home>/library/LNBlog. In that, go into the Listener folder, and edit the file called NavTab.php.

In it, you will see the following array:

Code:
            $extraTabs['blogs'] = array(
                'title'                => new XenForo_Phrase('lnblog_blogs'),
                'href'                => XenForo_Link::buildPublicLink('blogs'),
                'linksTemplate'        => 'lnblog_tab_links',
                'position'            => 'middle'
            );
Add the line below above the 'title':

Code:
                'image'                => '<patth to your icon>/blog.png',
Obviously, adapt the path to suit your needs.

You're done!

Now all we need to done is convince those who make add-ons to add an AdminCP option in their modifications to easily allow us to fill in the location, and we're all set :)

NavtabIcons.png

Enjoy :)

Peter - SchmitzIT
 

yavuz

Well-known member
#2
Nicely done Peter :) as you said it hopefully the devs would be convinced to allow adding icons to the navigation. Otherwise we would need to change evertime a new version is released.
 

SchmitzIT

Well-known member
#3
Nicely done Peter :) as you said it hopefully the devs would be convinced to allow adding icons to the navigation. Otherwise we would need to change evertime a new version is released.
I think I will simply delete the navtabs.php files from the add-on updates s in case the suggested option proves to be not viable. I would hazard a guess that the navtab itself will not change too drastically. And in case it does, it's only adding a single line to the code-file that'll do the trick.
 
#5
I have been looking for this for a long time, however I cannot get it to work.

I have replaced the lines in the navigation template, uploaded the icon and modified the NavTabs.php file

I have also double checked that the icon name and location is correct.


Edit: I got it working. I was being dumb and replacing the wrong code.

Fantastic mod. Thanks a lot for this!