Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Can I run php code on post body content?

Are there plugin or modified bbcode for run php code on vanilla's post content?

I want to include the php code into every post body for control format of contents.
Is it possible?

Thank you

Tagged:

Comments

  • Options

    You don't control the format by running php code in the post body, that is not how it works nor would it be desirable.

    Better idea is to explain what it is you want to achieve, rather than what you think the solution is.

    grep is your friend.

  • Options
    edited January 2013

    First of all, sorry for my little English and programming.

    On my target, i want to use vanilla for static content that I created only. (like CMS)
    I have a content database, I want to query and show it from vanilla's body code.
    I plan to execute php code (for query DB) on vanilla's body.

    My idea of code on body:
    [php]
    @require_once('scripts/post.php');
    showquery('parameter');
    [/php]

    The benefit of this, it can modify query and echo code later.

    Is this way possible?

    Thanks again

  • Options
    GaryFunkGaryFunk Senior Application Developer ✭✭

    Are you wanting to populate the body of the discussion with data from your content database?

  • Options
    x00x00 MVP
    edited January 2013

    You wouldn't do it that way.

    You create your own formatter, have a look at the formatters, like markdown, bbcode, etc. Also others like LaTex plugin use specific shortcode /substitution outside of main formatters. Even CMS like wordpress do not usually allow php to be injected directly into the post. That is very crude way of doing things, and even when they do it is a limited.

    Those that produce plugins that do this, do so becuase of lazy people, and there is no guarantee the author has properly assessed the implications.

    If what you want to do is show some query you could create a shortcode like so [myquery parameter=x]

    If what you want to is a specific type of post with special functionality, options, etc. Then implement that properly with plugin. Crow-barring php in the post isn't going to help. You are not even saving time long term.

    When you inject php, it is in some context, and most likely you have no idea the context. In other words if you have to ask this question, you are most likely approaching it wrong. There is a framework you are working in, it is not just a patchwork quilt of scraps of code.

    grep is your friend.

  • Options

    @GaryFunk said:
    Are you wanting to populate the body of the discussion with data from your content database?

    Yes

  • Options
    businessdadbusinessdad Stealth contributor MVP

    Let me see if I understood the flow:

    • You have an independent database of content that contains some entries (articles, posts, however we want to call them).
    • You want to extract the content of some (or all) items in the database and publish them as Discussions on Vanilla.
    • From that moment on, Vanilla should manage Comments, permissions and Users independently, but, if content changes on the database, the Discussion should be updated accordingly.

    Is that what you are looking for? In such case, @x00 is right, the proper way of doing it is using a Plugin that would understand shortcodes and fetch the data from the database on the fly.

    Personally, I would even store the content directly on Vanilla and avoid running a query to the external database every time. This would not allow to see the changes from the database as soon as they happen, but it might make sense, from a certain point of view, as it's not always appropriate to change a discussion that already received replies. Anyway, I'm going into too much detail now.

  • Options
    GaryFunkGaryFunk Senior Application Developer ✭✭

    @popcomputer said:
    Yes

    That's easy. I did exactly that at 4sqbadge.com with an external program.

    The content table has a field called forum which tells it what the discussion number is. Then anytime the external content is updated, the external program updates the discussion table. It's really simple and I can help you with the queries.

    I carried it a step further and have the external program insert new discussions when needed.

    Another thing you can to is use jquery to add data to each discussion.

Sign In or Register to comment.