A A A
Forum Scope


Match



Forum Options



Min search length: 3 characters / Max search length: 84 characters
Forum Login
Lost password?
coding-topic
moving 'start new topic'
RSS
Avatar
Chris_Andrews
70 Posts
(Offline)
1
Apr 13, 2017 - 12:48 pm
Print

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

16436 Posts
(Offline)
2
Apr 13, 2017 - 1:09 pm
Print

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
70 Posts
(Offline)
3
Apr 13, 2017 - 1:21 pm
Print

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

16436 Posts
(Offline)
4
Apr 13, 2017 - 1:26 pm
Print

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
70 Posts
(Offline)
5
Apr 13, 2017 - 2:52 pm
Print

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

19448 Posts
(Offline)
6
Apr 13, 2017 - 9:25 pm
Print

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

16436 Posts
(Offline)
7
Apr 14, 2017 - 4:46 am
Print

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
70 Posts
(Offline)
8
Apr 15, 2017 - 10:00 am
Print

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

19448 Posts
(Offline)
9
Apr 15, 2017 - 10:09 am
Print

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

19448 Posts
(Offline)
10
Apr 15, 2017 - 10:11 am
Print

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: America/New_York
All RSS Show Stats
Administrators: Blues Dancer, Simple Press, SP Community Support
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 629
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Newest Members:
Kundan Dheevar
Wally Harvey
n1 n2
James Schwinn
Jaroslaw Balczewski
Lu Hunter
Jocelyne McGeever
Matthew Wolze
Roger Coly
Forum Stats:
Groups: 7
Forums: 17
Topics: 10052
Posts: 79332

 

Member Stats:
Guest Posters: 606
Members: 16889
Moderators: 0
Admins: 3

Most Users Ever Online
499
Currently Online
Guest(s)
15
Currently Browsing this Page

1 Guest(s)