• Resolved wpress2010

    (@wpress2010)


    So, I have a Pods template that returns a bunch of Pods info, like this:
    <h2 class=”color_boxW”>{@post_title}</h2>

    <ul class=”proplist”>
    [if video_1]

    • See the 3D Video! {@video_1}
    • [/if]
      [if video_2]

    • See the Lifestyle Video! {@video_2}
    • [/if]
      [if video_3]

    • See the Virtual Tour! {@video_3}
    • [/if]
      [if video_4]

    • See the video! {@video_4}
    • [/if]

    • Something else just text
    • And this template gets called into a Divi module like this:

      <p>[pods name=”property” where=”category.name = ‘MyCategory'” template=”Props for Sale” orderby=”post_date DESC” shortcodes=1]</p>

      All of this works as expected. BUT – how to do a conditional in the Divi module so that if the Pods template returns no data (i.e. could happen if there are zero items in that category at the moment) the Divi module doesn’t display. Divi has the ability to show or hide modules based on conditionals – which can include the content of custom fields. I just can’t get my head around the logic required here.

      Can anyone point me in the general direction of how to set this up?

      TIA!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Jory Hogeveen

    (@keraweb)

    Hi @wpress2010

    You can best ask this question at the Divi support team. We do not control their modules.
    Maybe you can create separate conditionals for each field?

    Cheers, Jory

    Thread Starter wpress2010

    (@wpress2010)

    Thanks, I realize that. I am just trying to figure out the logic when the Pods conditionals return “nothing”.

    Plugin Contributor Jory Hogeveen

    (@keraweb)

    Hi @wpress2010

    This still would be a Divi conditional within that module, Pods doesn’t have such integration with Divi. That is why it’s best to ask Divi 🙂

    Cheers, Jory

    Thread Starter wpress2010

    (@wpress2010)

    Thanks, I guess it was no surprise that the Divi team didn’t know much about this. Divi does have some conditional module ability, but none of it relates to anything like the Pods coding. I was able to accomplish what I needed with Pods and CSS. I just used an [if] [else] statement to render different content if the returns were null.

    I had not noticed when Pods apparently added the [else] feature.

    It works perfectly, but the coding automatically turns some unrelated elements further down in the template a red color as if there were an HTML error, but there is not.

    Plugin Contributor Jory Hogeveen

    (@keraweb)

    Hi @wpress2010

    Our magic tags and template shortcodes are indeed totally unrelated to Divi.

    It works perfectly, but the coding automatically turns some unrelated elements further down in the template a red color as if there were an HTML error, but there is not.

    This is most likely because of actual incorrect HTML. Maybe within your if/else tags?

    Cheers, Jory

    Thread Starter wpress2010

    (@wpress2010)

    Yes, but here is what caused the red color:

    Originally, the conditional was intended to show one

    • element if a field existed, a different one if it didn’t, and then end the list:

      [if mlsid]

    • MLSID: {@mlsid}
    • [else]<li style=”list-style-type:none; padding:0; line-height:.5″> 
      [/if]

      While this worked, it threw the error. I changed it to this, and the red color went away:

      [if mlsid]

    • MLSID: {@mlsid}
    • [else]<li style=”list-style-type:none; padding:0; line-height:.5″> 
      [/if]

      So, the closing tag of the

      needed to be outside the conditional statements. I am not sure why the first version did not work, as the if/else just presents one bunch of code instead of another, depending on whether the condition is met. Either way, the
      is properly closed by

    .

    Plugin Contributor Jory Hogeveen

    (@keraweb)

    Hi @wpress2010

    Sorry I don’t see any difference.
    I do however see n issue in your code.
    You are only adding a <li> element if there is no value. If you are in a list context you should always render a <li> element.

    Besides the above, you are rendering an empty <li> element in the [else] statement, why not just remove [else]?
    You would simply have this:
    [if mlsid]MLSID: {@mlsid}[/if]
    Or in case you need a list UI:
    [if mlsid]<li style="list-style-type:none; padding:0; line-height:.5">MLSID: {@mlsid}</li>[/if]

    Not that I’m closing the <li> element as well with </li>! This is not mandatory in HTML5 but still best practice.

    Cheers, Jory

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to handle conditional based on template – Divi’ is closed to new replies.