|
Replace in output question
|
| smokeman |
Posted on 15-03-2012 21:38
|

Veteran Member

Posts: 960
Joined: 23/06/2006
|
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:
Posted on 15-03-2012 21:35
- so it becomes to eg;
Posted on 15-03-2012 21:35 | bla bla bla
How can I do that - if it's possible.
|
| |
|
|
| skpacman |
Posted on 15-03-2012 21:57
|

Member

Posts: 103
Joined: 23/04/2009
|
Normally, you'd be replacing something in the html source that looks like an html comment
like this:
Code<!--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.
|
| |
|
|
| Tyler |
Posted on 15-03-2012 22:04
|

Member

Posts: 160
Joined: 30/11/2011
|
smokeman - for what its worth Codereplace_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. |
| |
|
|
| skpacman |
Posted on 15-03-2012 22:05
|

Member

Posts: 103
Joined: 23/04/2009
|
heh, regular expressions are your friend
|
| |
|
|
| smokeman |
Posted on 15-03-2012 22:19
|

Veteran Member

Posts: 960
Joined: 23/06/2006
|
@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.
|
| |
|
|
| Tyler |
Posted on 15-03-2012 22:25
|

Member

Posts: 160
Joined: 30/11/2011
|
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. |
| |
|
|
| smokeman |
Posted on 15-03-2012 23:00
|

Veteran Member

Posts: 960
Joined: 23/06/2006
|
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:
Codeecho "<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:
Codeecho "<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:
Code$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 ?
|
| |
|
|
| Tyler |
Posted on 15-03-2012 23:08
|

Member

Posts: 160
Joined: 30/11/2011
|
you need to put '. before chars variable and remove single quote after $chars |
| |
|
|
| smokeman |
Posted on 15-03-2012 23:13
|

Veteran Member

Posts: 960
Joined: 23/06/2006
|
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 ;-)
|
| |
|
|
| Tyler |
Posted on 15-03-2012 23:23
|

Member

Posts: 160
Joined: 30/11/2011
|
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 15-03-2012 23:33
|
| |
|