News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Tag to show reader's name in message

Started by WhizzB, June 07, 2004, 09:22:25 AM

Previous topic - Next topic

WhizzB

Hi,

hope this is about the right place to ask this...

I'm  looking for a tag that would be replaced by the reader's user name, similar to
the {bbusername} tag in some other forums.

All I found about this issue was for IRC: 

> Woah...I just discovered the IRC "/me" little "Easter Egg"... 
> Are there any other such MODs already built in? Such as
> a "/you" function to display the reader's name?

but now, is there a similar thing for the posts on the forum?

I was told that <me> and </me> work on the forum too:
  [me=WhizzB] What are you looking for here? [/me]
that shows as
 
* WhizzB  What are you looking for here?
but that doesn't seem to have anything to do with getting the reader's name to the text.

Why I'd need this, is to write a story where the reader appears as one of the characters, so it's not really a question of life and death, but it'd be nice to get it working, anyway. So help is appreciated.

[Unknown]

This is not a built in feature, but you can add it.  The way to add it, however, will be changing in the next version.  For the current version:

Sources/Subs.php, Find:
// [me=Comment]does something[/me]
'/\[me=&quot;(.+?)&quot;\](.+?)\[\/me\](?:<br \/>)?/is',


Add after:
'~\[you( /)?\]~i',

And then find:
// Something "me" is doing.
'<div class="meaction">* $1 $2</div>',


And add right after that:
$context['user']['name'],

In the next version, you'll find this in the same file:
// [me=Comment]does something[/me]
'~\[me=((?:&quot;)?)(.{1,80}?)\\1\](.+?)\[/me\](?:<br />)?~i' => '<div class="meaction">* $2 $3</div>',


And add after it:
'~\[you( />)?\]~i' => $context['user']['name'],

-[Unknown]

WhizzB

Thanks a lot for the info.

Unfortunately I'm no admin on that site, so that stuff goes beyond what I can do  there  :-[  and the admin prefers to wait for the new version, before letting ignorant newbies hack his databases ;-)


Oldiesmann

That change doesn't involve doing anything with the database at all. Just point them to this thread and they can make the changes themselves.
Michael Eshom
Christian Metal Fans

nave

oh i really really like this. i think i'll add this on my board..

edit: as much i love this, i couldnt get it to work. i'm sure i did something wrong

[Unknown]

What happened?

Did you try it like this:

[you]

Or like this:

[you /]

Did it parse at all, just wrong, or not at all?

-[Unknown]

[MiNX]Tek

This is awesome, I have been wanting to add like commands to my forum (and my members wanted it as well) so.. now I can. You showed where the code is, but how to add my own? Like... I want to add a sarcasm code. So (without saying it later) you can do >>>

<sarcasm>That's the best thing I have ever heard!</sarcasm>

is there then a way to do this?

[Unknown]

Well, you could add...

'~\[sarcasm\](.+?)\[/sarcasm\]~i' => '-- $1 --',

I don't know how you'd want to format it, but basically you put in the second part the formatting.  So, that '-- $1 --' could be:

'<div style="color: green;">$1</div>'
'<div class="sarcasm">$1</div>'
'<div style="color: white; background-color: white;">$1</div>'

Or anything.

-[Unknown]

[MiNX]Tek


Winters

Hrm, I'm probably totally wrong here, but I'll ask anyway: Is this the way I could add a "spoiler" Tag? (Meaning: By clicking on a "spoiler" button, the poster makes her enclosed text invisible unless people mark it with the right mouse button. The reader, at first, only sees the spoiler warning.

[Unknown]

Yes... there is.  Why else would I have posted my cryptic reply to the "hide" topic?

Instead of '<div style="color: green;">$1</div>'... why not:

'<script language="JavaScript">var spolierid = Math.round(Math.random() * 10000); document.write(\'<a href="#" onclick="document.getElementById(&quot;spolier\' + spolierid + \'&quot;).style.display = &quot;&quot;; this.style.display = &quot;none&quot;; return false;">SPOILER: CLICK TO READ</a><span id="spoiler\' + spolierid + \'">\');</script>$1<script language="JavaScript">document.write(\'</span>\');</script>'

In theory, that shoudl hide it until you click to show.  If javscript is off, it won't be hidden at all.

-[Unknown]

[MiNX]Tek

OMG wow, that's a big "why not" replacement. Never heard of a "spoiler" tag. Hmmm, even more to contemplate about.

[MiNX]Tek

'~\[sarcasm\](.+?)\[/sarcasm\]~i' => '-- $1 --',
'<div style="color: green;">$1</div>'
'<div class="sarcasm">$1</div>'
'<div style="color: white; background-color: white;">$1</div>'


Why are their two color's? One white and one green? They are both refering to text right? Also, where in the Subs.php file do I put this?

[Unknown]

Sorry, that was an example of three *separate* things it could be.

-[Unknown]

[MiNX]Tek

Oh okay. But again, where do I put the code


'~\[sarcasm\](.+?)\[/sarcasm\]~i' => '-- $1 --',
'<div style="color: green;">$1</div>'


If I wanted to use that.

[Unknown]

Quote from: [Unknown] on June 07, 2004, 09:35:45 AM
This is not a built in feature, but you can add it.  The way to add it, however, will be changing in the next version.  For the current version:

...

In the next version, you'll find this in the same file:
// [me=Comment]does something[/me]
'~\[me=((?:&quot;)?)(.{1,80}?)\\1\](.+?)\[/me\](?:<br />)?~i' => '<div class="meaction">* $2 $3</div>',


And add after it:
'~\[you( />)?\]~i' => $context['user']['name'],

-[Unknown]

So, instead of the thing it says to add there, add:

'~\[sarcasm\](.+?)\[/sarcasm\]~i' => '<div style="color: green;">$1</div>',

-[Unknown]

[MiNX]Tek

#16
Okay, great thanks :) Wow, that was easy, lol. I just imagined it to be harder. I got it so that it's green, and bold. But how to I make it italicised? I'm looking in the other PHP files to try to find the code for italicze, but I'm not seeing it.

Anguz

#17
Quote from: [MiNX]Tek on September 16, 2004, 05:13:58 PM
Okay, great thanks :) Wow, that was easy, lol. I just imagined it to be harder. I got it so that it's green, and bold. But how to I make it italicised? I'm looking in the other PHP files to try to find the code for italicze, but I'm not seeing it.

'~\[sarcasm\](.+?)\[/sarcasm\]~i' => '<div style="color: green; font-weight: bold; font-style: italic;">$1</div>',

Edit:

Better even, create a new class in style.css named .sarcasm

.sarcasm
{
   color: green;
   font-weight: bold;
   font-style: italic;
}


and then change the above div tag to

<div class="sarcasm">
Cristián Lávaque http://cristianlavaque.com

CapriSkye

spoiler doesn't work :(

this is what i have

'~\[spoiler\](.+?)\[/spoiler\]~i' => '<script language="JavaScript">var spolierid = Math.round(Math.random() * 10000); document.write(\'<a href="#" onclick="document.getElementById(&quot;spolier\' + spolierid + \'&quot;).style.display = &quot;&quot;; this.style.display = &quot;none&quot;; return false;">SPOILER: CLICK TO READ</a><span id="spoiler\' + spolierid + \'">\');</script>$1<script language="JavaScript">document.write(\'</span>\');</script>',

CapriSkye

ok i did some search on google, and came up with this code,

<b>Spoiler:</b> <input type="button" value="Show" style="width: 45px; font-size: 10px; margin:0px; padding:0px;" onClick="if (document.getElementsByTagName('div')[2].style.display !='')
{
document.getElementsByTagName('div')[2].style.display =''; this.innerText = ''; this.value = 'Hide';
}
else
{
document.getElementsByTagName('div')[2].style.display = 'none'; this.innerText = ''; this.value = 'Show';
}">
</div>

<div style="width:50%">
<div style="display: none; margin: 3px; padding: 6px; border: 1px solid;">
This is a spoiler
</div>


now i just gotta find a way to put it in smf... ;)

edi67

Quote from: [Unknown] on September 15, 2004, 03:53:22 PM
Yes... there is.  Why else would I have posted my cryptic reply to the "hide" topic?

Instead of '<div style="color: green;">$1</div>'... why not:

'<script language="JavaScript">var spolierid = Math.round(Math.random() * 10000); document.write(\'<a href="#" onclick="document.getElementById(&quot;spolier\' + spolierid + \'&quot;).style.display = &quot;&quot;; this.style.display = &quot;none&quot;; return false;">SPOILER: CLICK TO READ</a><span id="spoiler\' + spolierid + \'">\');</script>$1<script language="JavaScript">document.write(\'</span>\');</script>'

In theory, that shoudl hide it until you click to show.  If javscript is off, it won't be hidden at all.

-[Unknown]

where i must try to put this comand for hide topic?
CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

Anguz

For new tags without attributes (parameters), like the sarcasm tag mentioned in this topic, you can now use this mod
http://mods.simplemachines.org/index.php?mod=48
Cristián Lávaque http://cristianlavaque.com


EG

#23
I would like to create a bbc tag, so that when used, a line of text is shown first, and then what the person types between the tag.

I think I need to use echo.... but I cant figure it out, keep getting parse errors :-\

Ravenous

I add an OoC(Out of Charakter) tag to my forum. What should i do with this code, that "Out of Charakter" is shown above that message like "Quote"?


Ravenous


[Unknown]

'~\[ooc\](.+?)\[/ooc\]~i' => '<div class="quoteheader">Out of Character:</div><div class="quote">$1</div>',

-[Unknown]

oSa

Quote from: [Unknown] on June 07, 2004, 09:35:45 AM
This is not a built in feature, but you can add it.  The way to add it, however, will be changing in the next version.  For the current version:

Sources/Subs.php, Find:
// [me=Comment]does something[/me]
'/\[me=&quot;(.+?)&quot;\](.+?)\[\/me\](?:<br \/>)?/is',


Add after:
'~\[you( /)?\]~i',

And then find:
// Something "me" is doing.
'<div class="meaction">* $1 $2</div>',


And add right after that:
$context['user']['name'],

In the next version, you'll find this in the same file:
// [me=Comment]does something[/me]
'~\[me=((?:&quot;)?)(.{1,80}?)\\1\](.+?)\[/me\](?:<br />)?~i' => '<div class="meaction">* $2 $3</div>',


And add after it:
'~\[you( />)?\]~i' => $context['user']['name'],

-[Unknown]

How can i add this tag using the custom bb code mod?

Rain501

#28
okie dokie..

1.1 is giving me beef..

in the subs.php file, firstly i tried adding this to the $codes array :


array(
'tag' => 'iframe',
'type' => 'unparsed_content',
'before' => '<iframe src="http://xyz.abc.com/$1.html" scrolling="no" frameBorder="0" height="240" width="104"></iframe>',
'after' => '',
),


which gives me errors...


Warning: main(/home/rain501/public_html/forums/Sources/Subs.php): failed to open stream: No such file or directory in /home/rain501/public_html/forums/index.php on line 48

Fatal error: main(): Failed opening required '/home/rain501/public_html/forums/Sources/Subs.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/rain501/public_html/forums/index.php on line 48


And the same if i tag that out side of the $codes object, above the 'bbc goes above this line' line.

I then tried sticking the full sarcasm tag, copied from above onto the line above the 'stick yer bbc code above this line' line.. ;)

Still the errors :(

Anyone willing to point out where i'm going wrong?

EDIT:

Sorted it by rejigging the Array vars, so its all gravy now :)

Vinspire

This is a build in function in SMF 1.1 RC 2 right ?

topdog2k

Quote from: [Unknown] on June 07, 2004, 09:35:45 AM
This is not a built in feature, but you can add it.  The way to add it, however, will be changing in the next version.  For the current version:

Sources/Subs.php, Find:
// [me=Comment]does something[/me]
'/\[me=&quot;(.+?)&quot;\](.+?)\[\/me\](?:<br \/>)?/is',


Add after:
'~\[you( /)?\]~i',

And then find:
// Something "me" is doing.
'<div class="meaction">* $1 $2</div>',


And add right after that:
$context['user']['name'],

In the next version, you'll find this in the same file:
// [me=Comment]does something[/me]
'~\[me=((?:&quot;)?)(.{1,80}?)\\1\](.+?)\[/me\](?:<br />)?~i' => '<div class="meaction">* $2 $3</div>',


And add after it:
'~\[you( />)?\]~i' => $context['user']['name'],

-[Unknown]

I know this thread is dead but I will ask anyways.  Can the [you] tag be modified so other information about the user can be displayed such as the users ip or email, etc...

Advertisement: