We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Allow PHP in posts.

Development and Programming

Lisa Wess's avatar
Lisa Wess
20,502 posts
20 years ago
Lisa Wess's avatar Lisa Wess

Ok, I’m learning PHP and I want to set up a weblog to chronicle the stupid mistakes.. er, well everything.

But, I need to execute PHP in entries to do this the way I want to. So, I need a plugin for it and I don’t know how to write it, clearly.

Anyone feeling nice and generous? =) Think of how helpful I’ll be if I know PHP! I mean, really…

sighs =)

       
Low's avatar
Low
407 posts
about 20 years ago
Low's avatar Low

It would be fairly easy to set up if:

  • you add a custom field to your weblog (textarea)
  • set the formatting to None
  • the entire contents of that field is considered to be php code

I could create a plugin like that would parse the php in that field for you in no time. But if you want to combine normal text and php code, then things become a bit more complicated… 😊

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 20 years ago
Lisa Wess's avatar Lisa Wess

If you can do that, Lodewijk, that would be perfect. I can just set up multiple custom fields, I have no problem with that.

Ideally, I’d prefer that within the code I could put something like [php] code [/php] and it parses that, so that I don’t need that many custom fields. But a simple plugin that simply executs the php in a particular field would work for me. By the time I need something more indepth maybe I’ll know how to make it myself 😉

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 20 years ago
Lisa Wess's avatar Lisa Wess

Lodewijk,

If it helps to see how I’ll be using it, here is the page in the weblog, and this is what I had started doing, when I realized a weblog would be perfect for it, if only I could execute php 😉

       
Low's avatar
Low
407 posts
about 20 years ago
Low's avatar Low

Check this out!

Works as described earlier.

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
about 20 years ago
Sue Crocker's avatar Sue Crocker

Lodewijk,

Works great for templates and entries.

Test blog for Rebecca

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 20 years ago
Lisa Wess's avatar Lisa Wess

Ugh, it’s encoding the < and > so the php isn’t executing. I can’t even think at 6:15, what’d I miss? text formatting set to none, and has been since the creation of the field, and I hit the checkbox anyway to do it recursively anyway. Allow all HTML is on. Type is textarea….. I made sure I typed it in as < > ;p

Just can’t t hink of which thing I’m missing. I left the plugin off the comment page to see why it wasn’t executing. But you can see in the first link in my previous message that it clearly isn’t.

For someone with over 5000 posts, I should know the answer to this. But I shall embarass myself since I can’t think at 6am. 😉

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 20 years ago
Lisa Wess's avatar Lisa Wess

Oh, and thank you Lodewijk, this is fantastic, especially once I’m over my brain-deadedness 😉

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 20 years ago
Lisa Wess's avatar Lisa Wess

Eh, I think it’s just encoding it so that it won’t execute, which means I don’t know why it isn’t on the front page.

       
Low's avatar
Low
407 posts
about 20 years ago
Low's avatar Low

Please note that you shouldn’t put any <?php ?> tags in the code. The pair tags of the plugin are substitution for that. Sort of. 😊

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 20 years ago
Lisa Wess's avatar Lisa Wess

Ah that fixed it. Did I miss it in the docs? blushes

       
Low's avatar
Low
407 posts
about 20 years ago
Low's avatar Low

Erm, well, since there are no docs, you didn’t miss it. But technically the <?php ?> tags aren’t part of php code itself, so I kind of implied it. 😉

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 20 years ago
Lisa Wess's avatar Lisa Wess

There are docs, in the plugin manager… =) They’re embedded into the plugin, and you wrote them so you must know that. 😉

I’m off to the aminal shelter to clean up their messes, I’ll be back in a few hours. No hints, jokes, wit, or sarcasm are implied anywhere in here. winks

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
about 20 years ago
Sue Crocker's avatar Sue Crocker

Yeah, you need to set the < to & l t ; – that’s a limitation to the process.

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
about 20 years ago
Sue Crocker's avatar Sue Crocker

Actually, I take that back. I didn’t have to swap out the < - just in the example code I needed to.

Example now includes screenshot

       
1 2 3 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.