Support Forum

moving 'start new topic'

CA Chris_Andrews
Chris_Andrews
Member

I’m customizing the Unified theme and would like to move the ‘start new topic’ button to the top of the forum.

I’m putting this: 

sp_PostNewTopicButton(‘tagId=spPostNewTopicButtonTop&tagClass=spButton spRight’, __sp(‘Start New Topic’), __sp(‘Start a new topic’), __sp(‘This forum is locked’)); 

in the spHead.php file where I want it to appear…. but the button doesn’t show. 

I’m thinking maybe it’s not defined at this point yet? Or am I barking up the wrong tree? 

14 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

I will have to double-check this but I suspect that the data the button function requires is not yet available. The other issue, of course, is that the spHead displays in all views and all forums. If the user is currently looking at, say, the group view page or their profile – which forum would be the target for a new topic?

I will ponder on this however…

CA Chris_Andrews
Chris_Andrews
Member

Opps, had missed that a user can’t choose the forum on the add topic form. Oh well, I may put this idea on the shelf for now 🙂 

YS Yellow Swordfish
Yellow Swordfish
Member

Performing a check on whether the user is in a forum view is easy of course but there is still that data to worry about.
I am still pondering and might try an experiment later

CA Chris_Andrews
Chris_Andrews
Member

I did try copying the 

# == Start New Topic FORM – OBJECT DEFINITION ========================

section to the top of spHead.php to see if that was something that was required for the button to work, but it didn’t seem to make a difference. 

MP Mr Papa
Mr Papa
Member

spHead is shown on all pages… and the needed data wont be there…  not sure where @yellow-swordfish was going, but will wait for his answer in AM…

YS Yellow Swordfish
Yellow Swordfish
Member

I took a look last night to see if there was any way we might be able to work it but afraid no luck. it would mean some re-engineering of core.

CA Chris_Andrews
Chris_Andrews
Member

I don’t understand why….. but this: 

if (sp_this_topic()){
sp_PostNewTopicButton(‘tagId=spPostNewTopicButtonTop&tagClass=spButton spRight topNewbutton’, __sp(‘Start New Topic’), __sp(‘Start a new topic’), __sp(‘This forum is locked’));

}

elseif (sp_this_forum()){
sp_TopicNewButton(‘tagClass=spButton spRight topNewbutton’, __sp(‘Start New Topic’), __sp(‘Start a new topic’), __sp(‘This forum is locked’), __sp(‘No permission to start topics’));

}

seems to work in spHead.php to put the button where I want it. 

If I don’t put it in an if statement, I don’t get any result. If I do, it works. That seems very odd to me.

In simple testing, the form works fine like this. I have not done extensive testing yet. 

Chris

MP Mr Papa
Mr Papa
Member

a bit surprising…  we dont normally call class functions like that since it be creating a potentially large object when doing so and its not needed…  this will create a topic view object and possibly a forum class object on every page load…  not insignificant resource usage…

have you checked your php error log?  wondering if any notices for doing this since not sure all the needed data would exist on non forum and topic view pages…  notices are mostly harmless but do fill up the error log if generated on every page…

if it works (it just might) and doesnt generate a lot of errors and you dont mind the page loading slow down for creating those large objects, it might hold true…

MP Mr Papa
Mr Papa
Member

oh, and you have to put in an if statement (so to speak) because those functions return a boolean…  just calling them would “work” but not doing anything for you..  they are designed to be the main loop of their respective page views…  and if true, start the page loop for displaying items…

that is, they are designed to be using in if statement or looping constructs…

CA Chris_Andrews
Chris_Andrews
Member

Thanks for the info – 

No php errors, but I did notice forum pages were loading slower. I’ll keep testing and figure out how to best handle that.

Thanks again!

MP Mr Papa
Mr Papa
Member

if all you are trying to do is determine if on forum view or topic view, I would suggest using sp_is_forumview() and sp_is_topicview()…

CA Chris_Andrews
Chris_Andrews
Member

Tried and those don’t seem to work, I guess that it’s that the object is not created.

YS Yellow Swordfish
Yellow Swordfish
Member

They are the best way to check for the current page view however. Using those wrapped around your code might prevent unnecessary data object loading.

MP Mr Papa
Mr Papa
Member

yeah, sorry, should have been more specific in my response indicating to ADD those to what you had so you only do it on the right page as Andy indicates..