SimplePortal
Customization => Custom Coding => Topic started by: 130860 on November 09, 2010, 02:39:49 PM
-
well this tips is on nneonneo' shoutbox and AjaxChat so I adapted to SimplePortal shoutbox :)
with this tip you can post notifications on your shout when a new topic is created, also, you can configure it so the notification appears only when a new topic is created on certain board you choose.
I only test it on a RC3 and RC4 board.
lets get started.
first open your Sources/Post.php and find:
notifyMembersBoard($notifyData);
and add after it:
global $user_info, $board, $scripturl, $boardName, $topic;
$smcFunc['db_insert']('',
'{db_prefix}sp_shouts',
array(
'id_shoutbox' => 'int',
'id_member' => 'int',
'member_name' => 'string',
'log_time' => 'int',
'body' => 'string',
),
array(
1,
$user_info['id'],
$user_info['name'],
time(),
'[color=red][b]New Topic: [url='.$scripturl . '?topic=' . $topic . '.new#new'.']'.html_entity_decode($_POST['subject']).'[/url][/b][/color]',
),
array('id_shout')
);
you can configure a little bit at this part:
1, is the shoutbox ID, by default the first shoutbox you create has the ID 1, change it to yours.
'[color=red][b]New Topic: [url='.$scripturl . '?topic=' . $topic . '.new#new'.']'.html_entity_decode($_POST['subject']).'[/url][/b][/color]',
is the message to be posted, it will look like this:
Username: New Topic: topic name and url
the [color ] [/color] and [b ] [/b ] tag will only work if you enable this tag in your shout's settings.
if you only want to show notifications from certain board only, use this:
$foros = array (1,2); // where 1 and 2 are the ID of the boards you want to post notifications from
if (in_array($board, $foros)) // check if its the right board
it will look something like this:
$foros = array (1,2);
if (in_array($board, $foros))
{
global $user_info, $board, $scripturl, $boardName, $topic;
$smcFunc['db_insert']('',
'{db_prefix}sp_shouts',
array(
'id_shoutbox' => 'int',
'id_member' => 'int',
'member_name' => 'string',
'log_time' => 'int',
'body' => 'string',
),
array(
1,
$user_info['id'],
$user_info['name'],
time(),
'[color=red][b]New Topic: [url='.$scripturl . '?topic=' . $topic . '.new#new'.']'.html_entity_decode($_POST['subject']).'[/url][/b][/color]',
),
array('id_shout')
);
}
hope you find it useful, this is not my code, this is just an adaptation from nneonneo' shoutbox and AjaxChat tips.
-
Great,
Is it possible to open the link in the same window?
Stef.
-
Is it possible to open the link in the same window?
[url
[iurl
-
When i kake it like that it shows like this:
Nieuw Topic: [i url=http://www.spirituelekaarten.nl/index.php?topic=592.new#new]Testen of het in de schreeuw komt.[/i][/color]
Here i maked i url, because here it works, but in the shoutbox i can not not click the link.
-
Shouldn't be space between "i" and "url".
-
I know, but otherwise i cannot show how it looks in the shoutbox.
-
Oh, right! "iurl" not in allowed bbc tags. Let's add it:
./Sources/Subs-Portal.php
$row['allowed_bbc']
$row['allowed_bbc'] . ',iurl'
-
This works, thanks.
Stef.
-
Thank you, nice Tip!
How can i exclude some boards? this "aray"-thing is not working for me...
-
can you post your full code and tell me the ID of the array you want to exclude.
-
well, the code i was using (in SMF2 RC2!) is:
$foros = array (4,5,40,68,60,61,19,14,15,53,50,56,51,62,63,64,65,13,16,43,69,70,71,72,73,58,59,17,66,67);
if (in_array($board, $foros))
{
global $user_info, $board, $scripturl, $boardName, $topic;
$smcFunc['db_insert']('',
'{db_prefix}sp_shouts',
array(
'id_shoutbox' => 'int',
'id_member' => 'int',
'member_name' => 'string',
'log_time' => 'int',
'body' => 'string',
),
array(
1,
$user_info['id'],
$user_info['name'],
time(),
'[color=red][b]Neues Thema: [url='.$scripturl . '?topic=' . $topic . '.new#new'.']'.html_entity_decode($_POST['subject']).'[/url][/b][/color]',
),
array('id_shout')
);
}
I have two boards, that i dont want to show in the shoutbox: board-ID number 42.0 and 54.0
-
you don't need to listed all your boards, try this code:
$foros = array (42,54);
if (in_array($board, $foros))
return;
else
{
global $user_info, $board, $scripturl, $boardName, $topic;
$smcFunc['db_insert']('',
'{db_prefix}sp_shouts',
array(
'id_shoutbox' => 'int',
'id_member' => 'int',
'member_name' => 'string',
'log_time' => 'int',
'body' => 'string',
),
array(
1,
$user_info['id'],
$user_info['name'],
time(),
'[color=red][b]Neues Thema: [url='.$scripturl . '?topic=' . $topic . '.new#new'.']'.html_entity_decode($_POST['subject']).'[/url][/b][/color]',
),
array('id_shout')
);
}
-
Hey prisoner 130860
Have been watching this like a hawk.
Is there a way to post links so only certain membergroups can view it.
I have admin only boards and specific boards for certain groups ie subscribers and teenagers.
-
looks like it is (almost) function now.
When i write a new topic in the excluded boards, i have an error after submit: i dont see the new topic, only the head (menu) from the forum. in the error-log there is "could not load the main template"....
please, can you help?
Is there a way to show answers, too - not only the new topic?
Good work and a great tip.
-
@Brack1 well, that will be complicated, it is far better to create another shoutbox and give permisisons to this new shoutbox so only certain membergroups cann see it and shout on it.
@Divecall what is the exact error you gave?
attach your Sources/Post.php file.
and no, currently this tip is using a function in smf that is used only for new topics.
-
thanks 130860 for your help.
Here is the post.php
-
Divecall your file seems fine, if you remove this tip the error goes away?
can you post the errors on your error log?
-
Well, my error-log is in german...
but you can see only, that is a Theme-error
and you can read:
http://localhost/myboard/index.php?action=post2;start=0;board=54
Cannot load the 'main' template
No File or number or something....
(like ever: File: [Path]/post.php), line: xxx - THERE IS NOTHING!)
Maybe the error is my XAMPP-Test-Area ???
-
well, I need to know if the error is related with this tip, the error still occurs even if you take away the edits this tip make?
can you post the line you getting the error? even if it is blank, it gave me an idea on where to look at.
-
Yes, the error is away, when i remove you tip.
Here is the screenshot:
-
ok, can you tell me the ID of the shout you're modifying? this tip supose to modify the shout with ID 1, but you need to change that to your actual shout ID
-
I have only one shoutbox...this is with ID 1
-
ok, try with this one:
$foros = array (42,54);
if (in_array($board, $foros))
echo '';
else
{
global $user_info, $board, $scripturl, $boardName, $topic;
$smcFunc['db_insert']('',
'{db_prefix}sp_shouts',
array(
'id_shoutbox' => 'int',
'id_member' => 'int',
'member_name' => 'string',
'log_time' => 'int',
'body' => 'string',
),
array(
1,
$user_info['id'],
$user_info['name'],
time(),
'[color=red][b]Neues Thema: [url=http://'.$scripturl . '?topic=' . $topic . '.new#new'.']'.html_entity_decode($_POST['subject']).'[/url][/b][/color]',
),
array('id_shout')
);
}
-
Wow! Thats amazing!
It is working. THANK YOU SO MUCH!
-
Thank you sooooo much for this tip - I am using this code
global $user_info, $board, $scripturl, $boardName, $topic;
$smcFunc['db_insert']('',
'{db_prefix}sp_shouts',
array(
'id_shoutbox' => 'int',
'id_member' => 'int',
'member_name' => 'string',
'log_time' => 'int',
'body' => 'string',
),
array(
1,
$user_info['id'],
$user_info['name'],
time(),
'[color=red][b]New Topic: [url='.$scripturl . '?topic=' . $topic . '.new#new'.']'.html_entity_decode($_POST['subject']).'[/url][/b][/color]',
),
array('id_shout')
);
It is working fine but when I upload a new game and the topic is created it doesnt show up in the sbox
the board for the arcade games is here http://robbie93andhotchildxox.net/index.php/board,4.0.html
how can I get each new topic to show up in the sbox when one is created? thanks.
-
does your shoutbox has the ID 1?
-
No my sbox has the ID 5 I changed the array to 5 on the code, most topics work but new topics created when a game is installed do not.
-
this code will only work for new topics created by members, if you have a mod that automatically creates a new topic, then this code won't show that topic.
-
Ahh, ok no probs - thanks for a great tip anyway.
-
few questions:
- If I want show as author of this shouts user with ID 80 - what I have to change?
- If I want to change text in shout to:
New topic [linked topic name] posted by [linked username]
How to do this? Is it possible?
-
dito the above. i want it to put the topic name rather than just "new topic"
-
Is there a way to show answers, too - not only the new topic?
I would love that :D
-
No help ??? :| :| :|
-
:'( :'( :'(
-
Doing it for messages will put a heavy load on your server, it is not recommended.
You can add the same piece of code right after this comment on the same file:
// Only send it to everyone if the topic is approved, otherwise just to the topic starter if they want it.
-
Sorry i am dutch where to put that code ?
-
Open the Sources/Post.php and find that exact line, put the code on the first message of this topic right after that comment line.
Or just attach the file here.
-
Thnx for the help here is mi attachment
-
use this one, make a back up of your site before tryig to use this file as its totally untested.
-
Didn`t work sorry ?
Not showing new post in te shoutbox
-
any error on the error log? this code was made for an old version of SO, perhaps its different on new version, I haven't checked the new version.
-
No errors but just dont show up ;)
-
Ok, lets put the query right after the call to createPost() then, not the best place but it should work.
-
No result grrrrrrrrrrrrrrrrrr
-
I tried to make it work with latest SP and code works partially - shouts are added in database, but shoutbox does not display them :|
-
I have only very briefly looked at the edits to Post.php from this thread & can see some possible issues.
- It is hard coded to only edit db data for shoutbox id#1
- JS needed to implement shouts (client side/dynamic)
SP already has a function to add the shouts to the db and can be called instead of implementing the db edits I see in that file. Imo this is not the issue though.. it is possibly the shoutbox id# (if the user has set up more than 1 shoutbox) & the need for client side js.
Here is a brief example:
global $context;
$shout = 'This is a test shout';
$shout_id = 1;
$context['SPortal']['shoutbox'] = sportal_get_shoutbox($shout_id, true);
sportal_create_shout($context['SPortal']['shoutbox'], $shout);
echo '
<script language="Javascript" type="text/javascript"><!-- // --><![CDATA[
sp_submit_shout(', $shout_id, ', \'', $context['session_var'], '\', \'', $context['session_id'], '\');
// ]]></script>';
130860,
The above uses shoutbox id#1 .. hard code that id#, another id# or create a drop-down option in SP admin menu to opt a specific shoutbox id#. The sportal_create_shout & sportal_get_shoutbox functions should work without having to include any SP php file as it is already previously loaded/used by SP.
One can just try adding the js after the db edits & it will probably work if that is the route opted.
-
Didn`t work sorry ?
Not showing new post in te shoutbox
Any update ???
I love to see any post to show up in the shoutbox please
-
Please ???