1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

If extrafield = y

Discussion in 'Templates, HTML, CSS, and Design Help' started by jason1971, Dec 14, 2013.

  1. jason1971 Customer

    Hi all,

    I am trying to get details from a certain extra field, but struggling a little with it.

    I would like to produce an 'if'' statement, so that if the answer in extra field id 17 is "Y" it produces the information in extra field id 18.

    Is this possible ?

    any assistance much appreciated

    Thanks

    Jason
  2. freeze2 Super Moderator

    I'm not sure if conditional statements are possible with extra fields...maybe Mike will have a little info on this.
  3. Mike-N-Tosh Owner

    Of course anything is possible, but in this case I don't think it would be easy. You'd really need to be more specific and provide greater detail about it. Where are you wanting to do this and why. Why are there two fields to begin with? Wouldn't it be easier to just create the field with the data input only. That way it either has a data or it doesn't and you don't need to rely on an extra extra field.
  4. jason1971 Customer

    Hi Mike.

    In my showlisting.tpl page I would like to use the {if} statement for 2 reasons.

    1st. I would like to show text in my search results when the answer to extra field 1=="Y" it shows the info in extra field 2 like so:
    {if} {get_extra_field id=$entry.id fid=1 =="y"}{get_extra_field id=$entry.id fid=2}{/if}

    2nd. I would like to show an image in my search results when the answer to extra field 1=="Y" like so:
    {if} {get_extra_field id=$entry.id fid=1 =="Y"} <img src="etc..">{/if}


    But I am not sure (even if its possible). I know {get_extra_field id=$entry.id fid=1 =="Y"} is wrong, but I am using it to show you what I want to achieve. Hope this offers you more insight Mike ?

    Thanks

    Jason

    PS: I found this in another thread, and wondered whether it could be modified to suit my needs ?

    {capture name='loc'}
    {get_extra_field id=$entry.id fid=11}
    {/capture}
    {if $smarty.capture.loc=="United States"}
    <td{if $entry.class<>""} class="{$entry.class}"{/if}>{get_extra_field id=$entry.id fid=12}</td>
    {else}
    <td{if $entry.class<>""} class="{$entry.class}"{/if}>{get_extra_field id=$entry.id fid=13}</td>
    {/if}
  5. jason1971 Customer

    any thoughts anybody please ?
  6. freeze2 Super Moderator

  7. Mike-N-Tosh Owner

    I still don't understand why you are using a separate field to do this. If it were me, I would do it like this:
    myextrafield <-- Field created in admin as optional (fid = 1)

    Then in your showlisting just simply get the field value. If it has a value for the listing show it and the pic, if not, show nothing.
    Code:
    {capture name="myextra"}
      {get_extra_field fid=1 id=$entry.id}
    {/capture}
    {if $myextra}
      put whatever you want to here...
      {get_extra_field fid=1 id=$view}
      <img src="........>
    {/if}
  8. jason1971 Customer

    Hi Mike,

    I tried what you suggested but I never worked. I will explain what I am trying to achieve then see if that helps with an answer.

    My website is for people to advertise their holiday homes to rent out, the reason for wanting the extrafield is for the advertiser to promote any special offers which would then show up in search results. I know I could just use the {get_extra_field fid=1 id=$entry.id} by itself.

    But I would like to either add a border or something in text like special offer, to really promote the fact they have a special offer, but I only want it to show up if they have a special offer ... Hope that help Mike...

    Thanks

    Jason.
  9. Mike-N-Tosh Owner

    The code that I posted does indeed work. If it isn't for you then there is something else wrong, like you don't have the correct fid or something else.

    As far as your explanation for using two separate fields instead of one, still makes no sense as using one field as I have shown still does what you are saying. They either have their promo text in the field or they don't. in other words, if the field is empty then it = "N", if it has promo text then it = "Y" without using another field.

    I have given you a workable solution and explanation as to how it works and even tested it on one of my dev sites. At this point, I can not spend more time on customizing your site for you.
  10. freeze2 Super Moderator

    Hi Jason, I'm still trying to make sense of what exactly you are trying to accomplish...I know it makes sense in your mind...but I can't figure it out.

    Why don't you give an exact scenario of what you are hoping to accomplish including what "extra field 1" might be and so on...there may be a more logical way to make this work.
  11. jason1971 Customer

    Hi Freeze

    I am using {get_extra_field fid=18 id=$entry.id} which is a Text Multi Line.

    If text is entered in to it I would like to add some like

    "Late Deal {get_field fid=1 id=$entry.id}" in showlistings

    but if the Text Multi line is blank nothing should appear.

    I really am sorry to have been a pain about this and for taking up any of your time Mike, it is just sometimes difficult for those of us who are not professional to explain in a way others need to know.

    Jason
  12. freeze2 Super Moderator

    Let's get a little more exact....what would the text be for "extra field 18" that the user would enter? What is "extra field 1" ?
  13. Mike-N-Tosh Owner

    Jason, There is no need to apologize as you didn't do anything wrong at all. The code that I posted will do exactly as you are saying, except the "fid=X" would need to be changed to whatever the REAL extra field ID number is in BOTH places in the code. Even in your examples, the fid didn't match which may be why it didn't work for you.
  14. jason1971 Customer

    Thanks Mike and Freeze the issue is now sorted and I can now stop with the headache tables :), thanks again for all your help guys, was just as Mike said.

Share This Page