ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Calculate with entry fields

August 09, 2012 10:22am

Subscribe [2]
  • #1 / Aug 09, 2012 10:22am

    webnology

    353 posts

    Hi,

    is it somehow possible to calculate with entry fields?

    Sth like = {customfiled} = {customefield} + 1

    MAny thanks,
    Michel

  • #2 / Aug 09, 2012 10:53am

    Spurlock

    14 posts

    There are EE Add-ons that will let you do math inside templates (here’s one, there are others),  I expect they would work with variables.

    The catch is going to be the assignment part. EE doesn’t do much in terms of assigning values to variables for later reuse. You can do preload replacement, but since it has to fit into a particular early spot in the parse order, you’ll find it’s not nearly the same as assigning variables in a typical programming language.

    So depending on what you’re trying to do overall, you may need to break out PHP. However I find that when you think you need PHP, typically it’s a sign that there’s an easier (or EE friendlier) way to accomplish whatever you’re doing if you just step back a bit.

  • #3 / Aug 09, 2012 5:37pm

    Kevin Smith

    4784 posts

    Spot on advice, Spurlock. Thanks for tossing in with that.

    Michel, did that advice get you pointed in the right direction?

  • #4 / Aug 10, 2012 2:53am

    webnology

    353 posts

    I’m trying it out right now. I’ll come back with an update.

    Regards,
    Michel

  • #5 / Aug 10, 2012 4:24am

    webnology

    353 posts

    What I actually want to do, is get a specific existing entry field from the channel ‘estimates’, add 1 to that field, and us the new value in a Safecracker entry form. I use it to create automatic increments for invoices and estimates. Will this work you think with the plugins, you think?

    Michel

  • #6 / Aug 10, 2012 2:38pm

    Kevin Smith

    4784 posts

    I’d give one of the free plugins a try first since that’s an easy thing to do. If that doesn’t work, I’d probably try using PHP. While you’re working on it, just be mindful of parse order.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases