Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Replace in output question

Asked Modified Viewed 2,136 times
S
smokeman
S
  • Veteran Member, joined since
  • Contributed 920 posts on the community forums.
  • Started 79 threads in the forums
  • Started this discussions
asked
Veteran Member

Hi folks.

I have a question about the replace_in_output() function.

If I want to insert something in viewthread.php right after this line:

Quote

Posted on 15-03-2012 21:35


- so it becomes to eg;

Quote

Posted on 15-03-2012 21:35 | bla bla bla


How can I do that - if it's possible.
0 replies

9 posts

S
skpacman
S
My PHP-Fusion site: https://skpacman.live
  • Member, joined since
  • Contributed 150 posts on the community forums.
  • Started 25 threads in the forums
answered
Member

Normally, you'd be replacing something in the html source that looks like an html comment

like this:
<!--forum_thread_user_name-->


I don't see anything unique in that specific spot that could be replaced though.

I assume you've already looked over this guide.

I haven't messed with output replacements much, but I do know you need to find something in the HTML output that is unique that you can replace.
0 replies
T
Tyler
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums
answered
Member

smokeman - for what its worth
replace_in_output('Posted on ([0-9_-\s\:]{1,20})', 'Posted on \1 | Blah');


works. I'm no pro.... check spelling I'm on my phone.
0 replies
S
skpacman
S
My PHP-Fusion site: https://skpacman.live
  • Member, joined since
  • Contributed 150 posts on the community forums.
  • Started 25 threads in the forums
answered
Member

heh, regular expressions are your friend
0 replies
S
smokeman
S
  • Veteran Member, joined since
  • Contributed 920 posts on the community forums.
  • Started 79 threads in the forums
  • Started this discussions
answered
Veteran Member

@Mittens Returns: Thx - that was exactly what I was looking for! Now I think I understand this in a better way too.

Thank you again. :)
0 replies
T
Tyler
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums
answered
Member

It is very handy. its real easy when there's specifics nearby... if you apply that code right you shouldn't have an issue but you could then be selecting say news post or similar... where ever you put it you could check for /forum/ in url then execute the code

glad it worked for you.
0 replies
S
smokeman
S
  • Veteran Member, joined since
  • Contributed 920 posts on the community forums.
  • Started 79 threads in the forums
  • Started this discussions
answered
Veteran Member

Ahh ok I see - good to know. I just make an url check for that part then.

I think I maybe explained myself a bit wrong before.. What you supposed is working like a charm. But if we look in the php code for that particular line I want to change then it look like this:

echo "<div class='small'>".$locale['505'].showdate("forumdate", $data['post_datestamp'])."</div>\n";

- and what I want to do I can easily do in the file itself:
echo "<div class='small'>".$locale['505'].showdate("forumdate", $data['post_datestamp'])." ".strlen($data['post_message'])."</div>\n";


And I thought I could solve it this way:

$chars = strlen($data['post_message']);

replace_in_output('Posted on ([0-9_-\s\:]{1,20})', 'Posted on \1 | $chars');


But that of course won't work. Is it possible what Im trying to do - if you understand what it is Im looking for btw ?
0 replies
T
Tyler
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums
answered
Member

you need to put '. before chars variable and remove single quote after $chars
0 replies
S
smokeman
S
  • Veteran Member, joined since
  • Contributed 920 posts on the community forums.
  • Started 79 threads in the forums
  • Started this discussions
answered
Veteran Member

Ahh yes - now I see.

I guess I have to make a new query then ? Because now it shows 0 in every posts. And I want it to count/show how many characters there are in every post.

Btw: It seems to me that you have some good coding skills. There are unfortunately many parts of PHP/SQL that I still yet have to learn - but hey, Im hanging in and trying to learn every day ;-)
0 replies
T
Tyler
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums
answered
Member

this only replaces content... php holds the html, it goes through the handler process and then renders the page. I wasn't paying much attention to your code... I understand what you want but if it is possible - which I think not - then I cannot do it. if you could select all of that and the post msg you could request the string length...

there's a lot of code between them... it probably is possible but I've got no clue on a viable way to sift through all that at once.

I know a little bit. I really pick and choose who to help but if you need something ill surely try to help. sorry I don't have your answer.
Edited by Tyler on 16-03-2012 01:33,
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 9 posts
  • Votes 0 votes
  • Topic users 3 members

3 participants

S
S
  • Veteran Member, joined since
  • Contributed 920 posts on the community forums.
  • Started 79 threads in the forums
  • Started this discussions
S
S
My PHP-Fusion site: https://skpacman.live
  • Member, joined since
  • Contributed 150 posts on the community forums.
  • Started 25 threads in the forums
T
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet