Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
coding-topic
moving 'start new topic'
Avatar
Chris_Andrews
Member
sp_UserOfflineSmall Offline
Apr 13, 2017 - 12:48 pm

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? 

***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Apr 13, 2017 - 1:09 pm

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...

andy-signature.png
YELLOW
SWORDFISH
Avatar
Chris_Andrews
Member
sp_UserOfflineSmall Offline
Apr 13, 2017 - 1:21 pm

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 🙂 

***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Apr 13, 2017 - 1:26 pm

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

andy-signature.png
YELLOW
SWORDFISH
Avatar
Chris_Andrews
Member
sp_UserOfflineSmall Offline
Apr 13, 2017 - 2:52 pm

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. 

***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 13, 2017 - 9:25 pm

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...

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Apr 14, 2017 - 4:46 am

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.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Chris_Andrews
Member
sp_UserOfflineSmall Offline
Apr 15, 2017 - 10:00 am

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

***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 15, 2017 - 10:09 am

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...

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 15, 2017 - 10:11 am

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...

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 649
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 616
Members: 17345
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10117
Posts: 79602