Support Forum

how to insert text into .php

SB Star Buck
Star Buck
Member

Hello,

 

since this is my first post, just let me say how great v5 is so far! 🙂
While trying out features, I had some idea to insert some fixed text somewhere in spTopicView.php (or anywhere else for that matter), so how do you add some text codewise in the php-file to show up in forum?

Also, if I want to insert a variable text like topicheader to for example make the permanent link also with text, how do you do that?

 

Example:

sp_PostIndexPermalink(‘tagClass=spButton spLeft’, ‘VARIABLE TEXT HERE’, __sp(‘The post permalink’));

Goal is that the button shows the icon for permalink and right next to it as part of the icon the topicheader as clickable text. Any help appreciated, thanks!

7 Answers

New Answer

MP Mr Papa
Mr Papa
Member

not sure what you are asking or what you want to do…  what do you mean by VARIABLE TEXT HERE?

that whole line is just php, so you can do whatever you want in php…  as you have it now, the text string VARIABLE TEXT HERE would be output… 

are you saying you want to change it up depending on something??  you could do:

$string = ….  # whatever you want to determine the string value

sp_PostIndexPermalink(‘tagClass=spButton spLeft’, $string, __sp(‘The post permalink’));

if you mean a different string based on circumstances… but you have to code up the determination of the string…

also, keep in mind that its a POST permalink, not a topic permalink, and needs to be within the post loop…

sorry if I am not following and have missed your question… please explain further if needed…

SB Star Buck
Star Buck
Member

Sorry for not being clear, but that trick with the variable just did it!

Thanks Mr Papa and also thanks for the whole v5 again, just amazing software being for free!!!

MP Mr Papa
Mr Papa
Member

okay cool! themes are just php, so you can do whatever php allows… we just provide some template tags and api for common items

SB Star Buck
Star Buck
Member

Can you just tell me how to get the topicHeader from this function

sp_TopicHeaderName(‘tagClass=spHeaderName spLeft’);

into a $stringVariable so I can print it elsewhere again?

 

$stringVariableHeader = sp_TopicHeaderName(‘tagClass=spHeaderName spLeft’);

just prints out the Topic on screen, but does not seem to store the topic as text.

 

Also, is there a common function for printing out text or $strings formatted with classes like ‘tagClass=spPostUserDate spRight’ ?

 

Thanks again for helping me understand sp.

MP Mr Papa
Mr Papa
Member

still not sure what you want… do you just want the topic name??  use variable $spThisTopic->topic_name

again, this is php… so if you just want to write out some text, do:

echo ‘my string’;

if you want the string to be html and have classes or ids, then:

echo ‘<p class=”some-class”>my text</p>’;

would write a paragraph containing ‘my text’ with a class of some-class…

for php reference:  http://php.net

SB Star Buck
Star Buck
Member

Thanks again Mr Papa!

So is there a list of all common variables for sp like $spThisTopic?

MP Mr Papa
Mr Papa
Member

well since 5.0 is still in beta, we havent updated all our online docs yet… will soon…

these are the general ones that we make available to themes:

global $spGroupView, $spThisGroup, $spForumView, $spThisForum, $spThisSubForum, $spThisForumSubs,
$spTopicView, $spThisTopic, $spThisPost, $spThisPostUser, $spListView, $spThisListTopic,
$spThisUser, $spProfileUser, $spMembersList, $spThisMemberGroup, $spThisMember,
$sfglobals, $sfvars;

but keep in mind, they are only valid in certain places… $spThisTopic for example would not be set on the group view page… and some, like $spThisPost, is only valid when within the post loop…