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

html and mysql

Discussion in 'XenForo Development Discussions' started by Lee, May 21, 2013.

  1. Lee

    Lee Well-Known Member

    For now, I have manually saved some content into a new table I have created in my xenforo database.

    This table is xenforo_articles, the field name is content. This is the php I am using to preform the query;

    class Callback_PageNode
        public static function 
    myfunction(XenForo_ControllerPublic_Abstract $controllerXenForo_ControllerResponse_Abstract &$response)
    $db XenForo_Application::get('db');
    $results $db->fetchAll('
                    SELECT *
                    FROM `xf_articles`
    $response->params['results'] = $results;
    What I want to do, is get the field called content in that table and tell it to format the html in my template. Basically, I want to allow a text editor to submit html into the table and then display it correctly, bypassing the xenforo bbcode editor. I will be the only person with access to this form, so security of the html isn't really an issue as such.

    What is the best way to achieve this?

  2. Chris D

    Chris D XenForo Developer Staff Member

    So it looks like you have all of your data now in the "results" parameter so you should be able to see that.

    In your template if you write: {xen:helper dump, $results} and load the page that should verify to you if it has the correct content.

    Once you're happy it contains the information, if you have multiple rows of data in the xf_articles table and you need to get all of it out into your page then you need:

    <xen:foreach loop="{$results}" value="{$result}">
    {xen:raw $result.content}
    Lee likes this.
  3. Lee

    Lee Well-Known Member

    So simple. I'm learning alot these last few days! Thanks for the help Chris, works like a charm.
  4. Lee

    Lee Well-Known Member

    Looking at this, it looks like I might be better creating an "application" rather than a page load, if I want to incorporate comments and other things it just seems easier for the dynamic content to use an application rather than page nodes. I can't think of a good, automatic way to generate the comment pages using nodes that's all. Back to the drawing board.

Share This Page