HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Pulling content of post to show in pocket

How would I go about showing the content of a specific post or latest post in a thread - in a Pocket ?

My search'fu abandoned me.

Pretty sure I have seen it described here somewhere.


  • Options

    If you have the right tools, your search'fu should always be under lock and key.

    I have always the most current vanilla core downloaded unto my harddrive /documents.

    Then I have Agent Ransack , a powerful software that searches every file very nicely.

    So, between this software and searching vanilla github's repo, I usually find nice interesting things.

    For example, tossing in the term "pockets" in agent Ransack brought this as 2nd result

    // library/SmartyPlugins/function.pocket.php
    function smarty_function_pocket($params, $smarty) {
        if (!class_exists('PocketsPlugin')) {
            return '';
        $name = val('name', $params);
        $result = PocketsPlugin::pocketString($name, $params);
    	return $result;

    Then doing a search of "smarty_function_pocket" in the forum, brings up only one post:


  • Options

    Now how this answers your question is another matter.

    But I hazard that it is possible to replace the content of that pocket ... because the last time I checked Pockets does not handle smarty or php code

  • Options

    So, here is a trick, this might help you.

    In your theme hook or plugin, get the data you want and echo it out to a JavaScript variable or object.

    Pockets support JavaScript, so you will be able find the variable with your data included (in this case your latest post content)

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    I don't see a benefit in using the Pockets plugin. That plugin isn't made for showing dynamic data. This is the code that transforms your pocket into what you can see on your web page:

       public function toString() {
           $plugin->EventArguments['Pocket'] = $this;
           if (strcasecmp($this->Format, 'raw') == 0) {
               return $this->Body;
           } else {
               return Gdn_Format::to($this->Body, $this->Format);

    While you could theoretically hook into this event and replace some placeholder text with the processed data, you can as well skip that extra step and write directly to the page with your own plugin.

    Using the Pockets Plugin would only make sense if you want to allow moderators to work with that in a dynamical way. YOu would have to define some kind of "template languge": e.g. {{DiscussionID:249}} and then you can hook into theevent shown above, parse the content and if it is {{DiscussionID:\d}}, you replace the content.

    But instead of all that you should better think about writing a module that takes the discussion id as a parameter and displays the content. Look at bleistivts Birthday Module plugin to see how such a simple plugin for a module needs to done.

Sign In or Register to comment.