Jump to content

Quote and url parsing on the back-end


Recommended Posts

I've knocked up a hook which effectively creates an easy way to discuss posts / topics in the admin forum. There's a theme hook which sticks an 'admin discuss' link on each post, and a code hook which creates a new topic in the admin forum, title being "Discuss: Post in TOPIC by POSTER, started by MOD", content being the original contents of the post and a url. The mod then gets redirected to the edit page for that topic so they can add comments to the first post, or just leave it as is. 

It works as it is, but I have two improvements I'd like to make.

1) I'm adding the <blockquote> code around the contents of the original content. Is there any way I can use IPS\Text\Parser or something else to conjure up the proper quote code? I'm currently doing something like

$content = "<blockquote>".$post->post."</blockquote>";

What would be much more elegant is something like

$content = IPS\Text\Parser::quote (1234);

I've looked at documentation and poked around in system\text\parser.php, but it's beyond me.

2) Actually this one doesn't matter much. Never mind. 


If anyone likes this idea I'm happy to share the code I'm using - but as you can tell, I'm above my pay-grade here (well, above my pay-grade as a coder, at least).

Link to comment
Share on other sites

Just now, Nathan Explosion said:

And then put it through the bbcode parser somehow?

Yeah, it's the somehow bit I'm stuck on... or does that happen when I create the topic? Can try tomorrow...

Actually no, as it won't know where to link the citation stuff to...

Link to comment
Share on other sites

The building of the quote box is done in javascript (ips.core.comment.js, function _prepareQuote).

$content = "<blockquote class='ipsQuote' data-ipsQuote><div class='ipsQuote_citation'><div class='ipsQuote_citation ipsQuote_open'><a href='#' data-action='toggleQuote'>&nbsp;</a><a class='ipsPos_right' href='{$post->url()}'><i class='fa fa-share'></i></a></div></div><div class='ipsQuote_contents ipsClearfix'>{$post->post|raw}</div></blockquote>";

Untested, but should work.

Link to comment
Share on other sites

Unfortunately not - I'm not quite sure what's happening, but if you look at a 'normal' quote in the database, there aren't actually any urls in there. It's building those from the data-ipsquote-contentcommentid, etc, information. So what I've ended up doing is recreating that, and it seems to be working. Not tested, and there's some hardcoded stuff in there which means it wouldn't work for, eg,  blogs, but it suits my purposes for now. Note some of the variables are mine, not IPS ones. Here's what worked:

$content = "
 <blockquote class='ipsQuote' data-ipsquote='' data-ipsquote-contentapp='forums' data-ipsquote-contentclass='forums_Topic' data-ipsquote-contentcommentid='{$post->pid}' data-ipsquote-contentid='{$reportedtopic->tid}' data-ipsquote-contenttype='forums' data-ipsquote-timestamp='{$post->post_date}' data-ipsquote-userid='{$post->author_id}' data-ipsquote-username='{$post->author_name}'>
	<div class='ipsQuote_citation'>
		{$post->author_name} said:

	<div class='ipsQuote_contents'>

Thanks for the help with this...

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...