Support Forum

Topic Icons and Post Icons

UN
Unknown
Member

Perhaps I am overlooking something here…

Is there a way to make it so that you see a different image when there are new posts made since your last visit? For example, when you read a topic the far left image is a light blue square. When you return back to the forum and a new post is made within that forum/topic, the square is darker to represent that a new post has been made. Right now I see the same image regardless if there is a new post or not.

Thanks for your time and help.

Jordan

20 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

We changed this in V5 to use the status icon instead. for example, in the Group View you will see the new post icon and clicking on it will popup a lost of the topics with new posts. In Forum View nothing pops up of course (because it is a single topic) but it only shows up if there are new posts.

I have opened a ticket to discuss here adding an option for an alternate main topic icon (on the left) but the new status icon already there is more powerful in the long run.

CF Conrad_Farlow
Conrad_Farlow
Member

Andy I have been thinking about this and have decided that the muddled old men that frequent our forum would benefit from this behaviour. I was thinking of have having a custom topic button that changes from brown to red when a the topic has a new post in it. In fact I have even considered putting an N in it like this wink

 

If you decide not to introduce this fair enough but if you were going to do it, how would you do it?

YS Yellow Swordfish
Yellow Swordfish
Member

It is already in the code and will be in the next update.

As always you can control this via the function arguments. For both Group View (i.e., a forum that has topics with new posts) and Forum View (topics with new posts) you can pass icon names in via the ‘icon’ and ‘iconUnread’ arguments.

By the way – when you get the next update you can also set a ‘truncate’ argument against any Group, Forum or Topic title.

CF Conrad_Farlow
Conrad_Farlow
Member

Andy so if I update via svn now the latest version will have the truncate and the alternate icon code in it? In order to use the icon and iconUnread what should I have in the code? For instance look at this:

             

# Column 1 of the topic row
                        # ----------------------------------------------------------------------
                        sp_ColumnStart('tagClass=spColumnSection spLeft&width=6%&height=50px');
                            sp_TopicIndexIcon('tagClass=spRowIcon spLeft');
                        sp_ColumnEnd();


How would I add the feature to this? An example of the truncate code would be useful as well? would it be something like

sp_TopicIndexName('tagClass=spRowName &truncate=120', __sp('Browse the thread %NAME%'));

120 being the number of characters?

YS Yellow Swordfish
Yellow Swordfish
Member

Yes – they are both available from our svn repository.

first  a quick note on passing arguments. You should never leave spaces between arguments EXCEPT where a space is needed. For example where we have ‘tagClass=spRowIcon spLeft‘ the space is required to treat those two separate classes individually.

But where you have entered ‘tagClass=spRowName &truncate=120‘ you should eliminate that space prior to the ampersand. This – however – is the correct way to use the truncate argument – with a character count. It will truncate any title to that number of characters and add an ellipsis to the end. This is what we do with the Quicklinks drop down lists.

As to topic and forum icons there has always been the argument for ‘icon=xxx.jpg‘. The icon file would need to be placed in the images folder of the theme. If an icon argument is not passed it uses the default which is spTopicIcon.png.

To add your own icon for the unread post condition then create the icon, place it in the images folder of the theme and then pass the iconUnread argument, literally as ‘iconUnread=xxx.jpg‘. Well – of course use the icon name not xxx! We use .png files for all the forum graphics but when passed as a function argument it can be any image file type.

CF Conrad_Farlow
Conrad_Farlow
Member

Brilliant Andy thanks once again for the fantastic support! It amazes me how well you guys do with full time jobs, it’s very appreciated by some of us!

As for the arguments I have plenty to learn and because there are periods of frenzied activity interspersed with long periods of inactivity so I forget stuff embarassed

I’ll have a go at implementing both the iconUnread and the truncate function tonight and I’ll allow guests so that people can have a look.

YS Yellow Swordfish
Yellow Swordfish
Member

Well you know I have to look at the code for every answer as I can never remember anything at all!

CF Conrad_Farlow
Conrad_Farlow
Member

Ok I’m confused now

                        sp_ColumnStart('tagClass=spColumnSection spRight&width=24%&height=55px');
                            sp_ForumIndexLastPost('tagClass=spInRowPostLink&truncate=35&nicedate=0&date=1&time=1&stackdate=1',__sp('Last Post'));
                        sp_ColumnEnd();

That works fine but this                   

  # Column 2 of the topic row
                        # ----------------------------------------------------------------------
                        sp_ColumnStart('tagClass=spColumnSection spLeft&width=48%&height=50px');
                            sp_TopicIndexName('tagClass=spRowName&truncate=40', __sp('Browse the thread %NAME%'));

does not.

    # Start the 'breadCrumbs' section
    # ----------------------------------------------------------------------
    sp_SectionStart('tagClass=spPlainSection spLeft', 'breadCrumbs');
        sp_BreadCrumbs('tagClass=spLeft spBreadCrumbs&tree=0$truncate=35');
    sp_SectionEnd('', 'breadCrumbs');

Nor does the breadcrumbs. Which silly schoolboy error have I made this time

CF Conrad_Farlow
Conrad_Farlow
Member

Right I am totally flummoxed!

In forum view the topic icon displayed defaults to ‘sp_TopicIcon.png’.

Looking the code in spForumView.php for my theme which is based on the default theme I see that the icon is defined as:

sp_SubForumIndexIcon('tagClass=spRowIcon spLeft');

and

sp_TopicIndexIcon('tagClass=spRowIcon spLeft');

So where is it declared that spRowIcon is sp_TopicIcon.png? I can’t find this anywhere in the theme. Where else would it be?

Anyway following on from Andy said earlier I uploaded an icon called sp_TopicIcon_new_post.png into the images folder of my theme and thought that

sp_TopicIndexIcon('tagClass=spRowIcon spLeft&icon=sp_TopicIcon.png&iconUnread=sp_TopicIcon_new_post.png');

It doesn’t work of course.

So the questions are:

  1. Am I passing the argument in the right place i.e spForumView.php
  2. Is the syntax correct?

Sorry but I have to learn this somehow, it’s great when it works and not so great when it doesn’t frown

Conrad

MP Mr Papa
Mr Papa
Member

all of the template tags defaults are defined in the appropriate php file where the code for that template tag is…  so you will need to look at the code to see the defaults…

this will change over time as we get our codex better populated…  we will have a codex page for each template tag including the defaults… just not there yet…

as a two man coding team and one guy helping out here and with themes and the codex, its going to take some time…

volunteers welcome!! cool

MP Mr Papa
Mr Papa
Member

oh… and should add that not every template tag has the truncate…  just titles…   the breadcrumbs were not considered a title…  so group name, forum name, topic name got the treatment…

CF Conrad_Farlow
Conrad_Farlow
Member

OK Steve so why does my second truncate example not work in that case, it is for a topic title I believe, fine on the breadcrumbs though although to be fair if you do not have nested breadcrumbs you could end up with problems. Imagine languages with long words?

So that’s what I am asking – where is the spRowIcon tag defined, which php file? I can’t find it and I have tried, honest! If I understand you correctly the tags are not separated into individual php files yet but it is your intention to do so eventually. At the moment the tags are in various php files, probably where they were first utilised?

Can you tell me why the code does not work, or give me an example of how to pass the argument iconUnread=xxx.png?Is it because I need to find where the tag spRowIcon is defined and pass the argument(s) there?

Do I need to pass the argument for both icons like this with respect to syntax?

('tagClass=spRowIcon spLeft&icon=sp_TopicIcon.png&iconUnread=sp_TopicIcon_new_post.png');

or need I only pass the argument for iconUnread? Perhaps then in the absence of an unread post the default icon will be used?

I think a few more examples and I’ll get it.

Sorry to be a pain.

YS Yellow Swordfish
Yellow Swordfish
Member

The real problem is not having the documentation in place yet of course.

It’s a shame that this thread has gone to a new page but I wil refer back best I can.

You said that truncate on sp_TopicIndexName did not work. I can not explain why as your syntax looks fine and it most assuredly does work on my site.

While using truncate in sp_BreadCrumbs will not currently work anyway you did actually use a $ instead of an & to separate the arguments which would have been incorrect. As it happens NOT adding support for this to the breadcrumbs was just an oversight on my part and I will add in support for that today.

Your use of iconUnread in sp_TopicIndexIcon again looks to be fine although my eyesight is not what it once was! Again this works perfectly for me on my test sites so if not for you I am unable to explain. I am assuming that the forum you tried it on did in fact have topics with unread posts!

Finally – you did reference the function sp_SubForumIndexIcon which again should be OK to use except again I missed this one and will correct that today. Sorry – put it down to the bout of flu I am still trying to shake off. embarassed

Right – today’s lesson!

Every template function is defined with a set of default arguments. If no arguments are passed to the function when it is called, the defaults are automatically used. So – to take up your example – it is not necessary to pass the icon name ‘sp_TopicIcon.png’ – which is the default – unless you want to replace it with an icon of a different name. As it stands, I have defined the default ‘iconUnread’ to be the same as ‘icon’ (we may change that but have not decided yet). So, if you do want an unread icon to be used it IS necessary to pass this as an argument.

If you look at all the files in the ‘templates’ folder of a theme and concentrating on the base forum templates only, they are split into Group, Forum and Topic Views plus Head and Foot templates.

if you now look in the SP folder simple-press/forum/content you will find the template function code files. Group, Forum and Topic views are obvious. The Head and Fot function are in the ‘common-view’ file because these are used on all pages.

So – for an example – with no documentation in place, if you need to look at the default arguments for the template function sp_TopicIndexIcon – this appears in the spForumView template and the function itself is in the sp-forum-view-functions.php file. And where that function is defined you will find immediately the list if available arguments and their default values – all of which can be overridden when called by a template.

So endeth today’s lesson. Explore away!

CF Conrad_Farlow
Conrad_Farlow
Member

Oh I assuredly will! I’ll let you know how I get on.

Thanks very much for that Andy it is most informative.