Support Forum
In the TopicView and ForumView (or any template file, for that matter) - I'd like to change a few things, like buttons + text, graphic elements, etc. I'd like to run a simple conditional statement. I've switched on the Data Inspector, which tells me forum ID, slug, etc. But how can I run a simple conditional in the above templates? Something akin to:
do stuff
} else {
do other stuff
}
Yes - just like that. Except you will need to use the object name and element. So - depending on what view you are in, it would not be just forum_id but $spThisForum->forum_id.
The data inspector (nice to see someone using it) should be able to show you which top level object names to use and what data is available in each data object but if you need help identifying one just shout.
YELLOW
SWORDFISH
|
Perfect! To be sure, the data inspector's data was a bit...data heavy. I'm a novice with PHP, but it was helpful at least in showing what I can target from the array of data.
I just tried a conditional (yours above) and it works great in spForumView.
A simple question: I simply want to hide the "start a new topic" button on one of our forums. We don't want people starting a new topic within this specific forum.
This works in the spForumView:
if ($spThisForum->forum_id == 8) { echo ''; } else { sp_TopicNewButton('tagClass=spButton spRight login-btn-grn', __sp('Start New Topic'), __sp('Start a new topic'), __sp('This forum is locked')); }
How can I adapt this to the spTopicView? We want the "add new topic" button to go away in any of the four topics we have in this forum (id = 8). Do I have to run something like $spThisTopic for each of the four, or is there a more global conditional based on the parent forum's id I can run?
Well, it doesn't seem to work, alas. Yes indeed, all four topics are in the one forum. But in spTopicView, this works:
if ($spThisTopic->topic_id == 738) {
echo '';
} else {
sp_PostNewTopicButton('tagId=spPostNewTopicButtonTop&tagClass=spButton spRight login-btn-grn', __sp('Start New Topic'), __sp('Start a new topic'), __sp('This forum is locked'));
}
While this does not:
if ($spThisForum->forum_id == 8) {
echo '';
} else {
sp_PostNewTopicButton('tagId=spPostNewTopicButtonTop&tagClass=spButton spRight login-btn-grn', __sp('Start New Topic'), __sp('Start a new topic'), __sp('This forum is locked'));
}
I suppose I can use the "or" statement to match the ID's of all four topics, but was hoping to slim it down with the more global "if is forum ID" statement.
You can save more and clersan it up firther by just testing for a false. So instead of
if ($spThisForum->forum_id == 8) {
which needs the dummy echo and the 'else' statement - just test for that being false. So it becomes if NOT forum_id of 8:
if ($spThisForum->forum_id != 8) {
which you do with the != comparator.
YELLOW
SWORDFISH
|
Ah, indeed. I ended up using the if/else format so that we could commandeer the text on one of the buttons, in one of the forums.
http://www.ornishspectrum.com/.....-to-knows/
In that forum, we're using a disabled "add new topic" button (we only want to keep responses tailored to the four Topics), and we're using different text on the forum's "add your reply" button.
Your code above works great, though - many thanks for the help!