Customizing SMF > SMF Coding Discussion
A Link viewable by member groups
(1/1)
Springer:
I have pjirc working and I would like to create a link (text or button) somewhere on SMF to have the pjirc java popup in a new window. The two are not intergrated. Pjirc does not need any input from the user. The link itself should be the easy part.
Here is where I need help. The link needs to be viewable based on member group, and in a way that it is not dependant on theme.
If it is possible I would like to add the link to the right of a board name, and anyone who can see that board can see the link.
Such as:
Private Board Link
Category1
Category2
Seems like that would be a good way to get past it being theme dependant and cover permissions. Of course I do not code and am probably completely wrong. I am willing to put the link most anywhere so long as it does the above things.
[Unknown]:
You could use something like:
if ($board['id'] == ##)
echo ' <a href="chat.html">chat!</a>';
-[Unknown]
Springer:
Decided to just break down and use the theme.
I want to add button at the top for chat. Depending on what group you are in you get a differently linked chat button.
In this post it said I needed to add a definition to the language file. But what determines the number you use?
If I want to add a button for homesite it is already in this correct?
--- Code: ---$txt[96] = 'Website';
--- End code ---
So I add something like this for chat.
--- Code: ---$txt[##] = 'Chat';
--- End code ---
Now on the template I have to add something like this? (forgive my code, it is bringing several examples together as best as I understand them.
--- Code: ---if ($board['id'] == ##)
<script>
function openpopup()
{
var popurl="LINK"
winpops=window.open(popurl,"","width=680,height=480,")
}
</script>
echo '
<a href="javascript:openpopup()">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/chat.gif" alt="' . $txt[##] . '" border="0" />' : $txt[##]), '</a>', $context['menu_separator'];
--- End code ---
Do again for a different ID value and LINK to have it where other gropus see the chat button but are sent do a different channel. (I have the pages for LINK already setup) As for the ID value what if I want to include more than one? Such as both group ID 1 and 2 should be able to see this link.
Oldiesmann:
For the number - in order to make sure you don't re-define a text string someplace, use a really large number (such as 999) or a text string (ie $txt['chat']).
For the code, it would probably be best to add the <script> stuff to index.template.php in the <head> section. Then, go into Boardindex.template.php and find:
--- Code: --- <a name="b', $board['id'], '"></a>
<b>', $board['link'], '</b><br />
--- End code ---
And change it to:
--- Code: --- <a name="b', $board['id'], '"></a>
<b>', $board['link'], '</b>';
if($board['id'] == ##)
echo'<a href="javascript:openpopup()">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/chat.gif" alt="' . $txt[##] . '" border="0" />' : $txt[##]), '</a>';
echo'<br />
--- End code ---
If you want to use the same link for multiple board IDs, you should just use a bunch of if statements:
--- Code: ---if($board['id'] == ### || $board['id'] == ##)
//echo the link here
elseif($board['id'] == #### || $board['id'] == #)
//echo a different link here
...
--- End code ---
If you're only using one link, you could also do this:
--- Code: ---$valid_ids = array(###,##,#,####);
if(in_array($board['id'],$valid_ids))
//echo the link here
--- End code ---
Springer:
ID_Cat=##
Could this be used instead of ID to cover many permission groups?
Navigation
[0] Message Index
Go to full version