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

evaluating response from a plugin?

Development and Programming

mtopper's avatar
mtopper
2 posts
15 years ago
mtopper's avatar mtopper

Hi, I’m new to expression engine so maybe this is a stupid question or there is a better way to go about it and i’m open to ideas.

I’ve created a plugin that will take parameters and insert data into a custom table i setup in the database. It will then return the id of the row it created in the database or an error message if it couldn’t insert the info into the database.

I would love to somehow be able to set variables somehow (either from the output of the script or somehow inside the plugin to be able to conditionally set something else up

something like:

{exp:academy:add_reservation foo="bar" .... another_variable="another value"}
{if reservation_id == "-1"}
PRINT ERROR MESSAGE
{if:else}
<input type="text" name="reservation_id" value="{reservation_id}"/>
{/if}
{/exp:academy:add_reservation}

is that possible? so that iw ould somehow setup the “reservation_id” inside of my plugin to be used like that?

if not is there anyway to retrieve the response from a plugin tag call to be evaluated within either php or just through the template tags?

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

Usually the way you’d handle this is by creating an {if no_results} type tag. See the comments in the template class docs.

I hope that helps!

       
mtopper's avatar
mtopper
2 posts
15 years ago
mtopper's avatar mtopper

But what if I want to be able to specify more than one error message? is there any way to retrieve the response into a tag variable to evaluate afterwards? or is there some other way this is accomplished?

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

Generally you’d use the no_results for no results returned, and conditionals (if you have a count variable available) for other evaluations. So you’d want no_results and count, at the least, available in your module.

       
mtopper's avatar
mtopper
2 posts
15 years ago
mtopper's avatar mtopper

can you explain what you mean by conditionals or give me an example on how that would be used?

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

You can read about adding conditional variables to your add-on in the development docs. You’ll need to figure out what you want to compare, and make sure that information is run through prep_conditionals so that you can use it in comparisons.

       
Alagko's avatar
Alagko
5 posts
one year ago
Alagko's avatar Alagko

The good news? Ensuring their safety doesn’t have to be overly complex or expensive. Most burglars abandon their attempts if they don’t succeed quickly. Addressing weak points in your home’s defenses can make all the difference.

       
Alagko's avatar
Alagko
5 posts
one year ago
Alagko's avatar Alagko

Why Investing in Security Pays Off. Carelessness and misplaced trust often give criminals easy access locksmithcal.com. Even securely locked windows can be relatively simple for experienced burglars to bypass.

       

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.