html and mysql

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;

PHP:
<?php
 
class Callback_PageNode
{
    public static function myfunction(XenForo_ControllerPublic_Abstract $controller, XenForo_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?

Thanks!
 
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:

Code:
<xen:foreach loop="{$results}" value="{$result}">
{xen:raw $result.content}
</xen:foreach>
 
  • Like
Reactions: Lee
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:

Code:
<xen:foreach loop="{$results}" value="{$result}">
{xen:raw $result.content}
</xen:foreach>

So simple. I'm learning alot these last few days! Thanks for the help Chris, works like a charm.
 
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.
 
Top Bottom