1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Confused about how to parse IMG tag

Discussion in 'XenForo Development Discussions' started by JoeMurray, Sep 1, 2011.

  1. JoeMurray

    JoeMurray Member

    I'm sorry if there is another thread about this, but I couldn't find it :/

    The thing is: I'm trying to retrieve content from threads/posts to custom pages, and use XenForo parser to parse content. I already know how to instantiate the parser, and use it, and I can parse content virtually everywhere. My problem is about how the parser renders the Html code of the tag.

    In threads, if I choose to show as the full image, it shows without problem. When I try to reproduce this over a custom page, it shows only a link like "Attachment 999". I managed to solve this by creation pages using the whole MVC system, in a manner that the content is being parsed over the view of each page. But this is not what I would like to do, because i'm really interested in using custom pages by just creating them via the ACP, and parsing content via the callback feature. The typical approach, and what I have been trying, is to use this over the page callback:

    $parser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base'false));
    $var "[b]hello[/b]";
    $parsed_var $parser->render($var);
    Is there a way to parse the bbcode via the callback, and get the images to be shown as they are in normal threads?

    Sorry if i'm not being clear about my problem. I'm from Latin-America, and my english might be a little poor.
  2. JoeMurray

    JoeMurray Member

    Please help me :(

    In summary, what I need to do is to stop getting this: "View attachment X", and start getting an image :/
  3. ragtek

    ragtek Guest

    Check method renderTagAttach in XenForo_BbCode_Formatter_Base to understand the problem;)

    If you don't send a view object to the create method it will return only the link

            if (!$this->_view)
    '<a href="' XenForo_Link::buildPublicLink('attachments', array('attachment_id' => $id)) . '">View attachment ' $id '</a>';
    JoeMurray likes this.
  4. JoeMurray

    JoeMurray Member

    OMG, I saw it some days ago but didn't get it :whistle: maybe I should take a break :D

    However, I always suspected that giving a view to the create method would solve the problem (because parsing things over the views, and giving the objetct to the function worked and showed the images), but I can't understand how to give a view to it outside a view. I must get an instance of a view? Which view? Please explain me with apples!

    Sorry, I'm somehow new to MVC coding ^^
  5. JoeMurray

    JoeMurray Member

Share This Page