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.

Conditional Variables: A Better Way to do This?

September 27, 2009 8:27pm

Subscribe [1]
  • #16 / Sep 28, 2009 1:09am

    Dale-

    63 posts

    Oops! Sorry, I forgot to reply to your mention of tags and the Solspace module. I have had the tag module bookmarked since my first considerations of EE (and may have already downloaded it). Thank you for adding it to this discussion. I have not installed the module, but think that this may be a good solution to consider. At first blush it seemed like a lot of tool for something so simple as selecting one of 4 or 5 small price tables, but it may be just the ticket.

    Prior to doing this stuff I was more comfortable with relational database design (at a modest level), and I swear that gets in the way quite often for me when working in a controlled CMS. Just need more time and study.

    I’ll see if the tag module will work for this before my content gets much deeper and causes me a lot of work to update all of the records, err, I mean entries.

  • #17 / Sep 28, 2009 1:15am

    Dale-

    63 posts

    You could nest a weblog entries tag inside the gallery entries tag, and pass your variables via embed.  That is an option but it will lead to using many conditionals that need to be updated in the template if you expand.  That’s why I’m trying to help you find a more dynamic and scalable solution here.

    And I’m listening. I’d prefer a dynamic and scalable solution because I have confidence that I’ll be able to reuse it. I’d love to find an elegant solution to what on the surface looks rather simple to me, but is turning out to be a bit of a kludge (my fault).

  • #18 / Sep 28, 2009 1:30am

    Lisa Wess

    20502 posts

    Dale,

    EE is a lot to learn and even after years you may still discover new things.  I bet 5 sites down the line you look back at this one and go, “why didn’t I do this THEN?!”. 

    I think the biggest complaint you’ll have with the tag module for this usage is that you can’t pre-define and restrict to certain tags.  That’s more of a training issue and there may be around it with Tag.

    I’m also hoping that others will have some ideas and jump in here with them. =)

    Now here’s something I haven’t worked with and have no idea how you’d make it work here - but there is FieldFrame, which includes FieldFrame matrix.  Then there is Playa 2 which gives you multi-relationships.  Some combination of these could likely be leveraged for your project, but again, I have not worked with them personally so I’m not sure, but it’s surely worth looking at and considering.

  • #19 / Sep 28, 2009 1:41am

    Dale-

    63 posts

    Lisa,

    I’m sure you’re quite right about looking back and wondering why I made it so difficult.

    Funny you should mention FieldFrame, as I have that in my “stash” of tools to learn about. I was reading a little about it a while ago, but know nothing really useful about it. I’ll make a point of looking at it again soon.

    Do you think that if I leave the current code in place, and add nothing new, that I’m likely to meet with a problem while I sort this out? I’m referring to the “unbridled custom_fields” in the conditional statements? Is there a concern that it will corrupt something, or just end-up breaking when certain new code is added which may cause a collision? I’d prefer to leave it instead of stripping it back to a hard-coded embed of a single table (which will be incorrect for some images). I have other options with multiple embeds as well, but it appears to be working now. I’m only referring to a period while I rethink it / learn a better solution.

  • #20 / Sep 28, 2009 1:53am

    Lisa Wess

    20502 posts

    Well, Dale - I honestly don’t think that code is working even if it looks like it is now.  Unless it is nested in a gallery entries tag that you didn’t show? 

    I think if it’s running fine now there’s no harm in using it while you work out a proper, permanent solution.  My concern would be that if you have a “working” solution you may not have the impetus to find a great solution.  So my main suggestion would be to make sure that fixing this is a priority. =)

  • #21 / Sep 28, 2009 2:10am

    Dale-

    63 posts

    Lisa,

    Wise advice, but be sure that this will bug me to the point of fixing it! Currently, it is working on all images, including new uploads (as tests).

    The whole section, together with others is wrapped in entries tags. I didn’t post that because I didn’t realize I might have problem at the time. This is probably why it’s “working”. The page is complete, and not just a test div, i.e. header, nav, footer, etc. I felt that posting the rest would add a lot of confusion, but apparently I left a key component out. 😉

    Dale

  • #22 / Sep 28, 2009 2:23am

    Dale-

    63 posts

    For a bit more clarity, after revisiting the template: I have {exp:gallery:entries gallery="{gallery_name}” } and its closing tag surrounding all of the divs in this affected content section. Does that make you a bit more comfortable with the custom_field variables?

  • #23 / Sep 28, 2009 4:33am

    Lisa Wess

    20502 posts

    That means that your conditionals will work, but bear in mind that your conditionals/weblog entries tags will run for every iteration of the gallery entries pair.  So if it outputs 10 entries, all of your code will process 10 times.

    That, combined with the advanced conditionals and other optimization issues, is definitely something that needs to be rectified.

    Make sense?

  • #24 / Sep 28, 2009 10:57am

    Dale-

    63 posts

    Yes it does make sense, and the kind of guidance I was hoping to find. Thank you.

    Now I just need to figure out the best way to do that. 😉 It would be pretty easy for me to remove the advanced conditionals and use just one simple conditional on a single custom_field. It would limit flexibility a little, but that’s not a big deal in this particular case.

  • #25 / Oct 05, 2009 7:11pm

    Lisa Wess

    20502 posts

    Hey Dale -

    I happened to have this on my bookmarks list, figured I’d check in and see how you’re coming along. =)

  • #26 / Oct 05, 2009 7:39pm

    Dale-

    63 posts

    Hey Lisa,

    I’m glad you checked in on this. I’m not completely finished/satisfied with my current implementation, but I have have trimmed the “if/else” section to reduce server load (only three options). I have also looked at handling this element via php in the template using “switch/case”, which should stop the conditional comparisons once a positive one is hit (the first two fit 95% of the entries). This may be the more “correct” way to do it. I’ve not used third-party tools with EE (other than a few plugins) so I’ve first wanted to sort through more of those at Solspace et al in case I can get double-duty from something. And I can change the advanced conditionals to simple conditionals with one more modification to my price tables. That may be what I settle on.

    I’m also wanting to better control the granularity of permissions to view certain categories in a “client” gallery, so I’ve been looking at options there and wanting to be sure that any modules, extensions, etc. would play nicely together. I’ve gotten a little distracted during the passed few days with another project under greater “crunch” pressure, but hope to come back to this soon because it’s more enjoyable than that which is demanding my attention today. 😊

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

ExpressionEngine News!

#eecms, #events, #releases