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.

Link to search result page stops working

November 08, 2012 7:10am

Subscribe [2]
  • #1 / Nov 08, 2012 7:10am

    Magnusvb

    57 posts

    Hi
    I have a simple search, and I want to have a banner (located on another page) linking to the search result on the result page.

    Doing a search, the URL looks like this:

    <a href="http://skola.studioalice.se/min_skola/resultat/8eaa3d24241fb8a82a824d03e7ddf0f4/">http://skola.studioalice.se/min_skola/resultat/8eaa3d24241fb8a82a824d03e7ddf0f4/</a>

    If I use that as a link, it stops working after a while. Is is possible to correct?

    Regards, Magnus

  • #2 / Nov 08, 2012 11:15am

    glenndavisgroup

    436 posts

    Hi Magnus,

    What version of EE are you using?

    Can you post the HTML code for your banner so I can have a look?

    Thank you,

    Mike

  • #3 / Nov 08, 2012 12:11pm

    Magnusvb

    57 posts

    Hi Mike
    Here are the html code (embedded on the page):

    <div>
      {exp:channel:entries
        channel="banner"
        status="open|riks"
        dynamic="no"
      }
      <a href="http://{banner_lank}">{banner_bild}</a>
      
    
      {/exp:channel:entries}
    </div>

    At just this moment I created a banner with a link on this page: http://skola.studioalice.se (staging server)
    It’s the top banner on the right side with the yellow text “Vinn biobiljetter”

    Regards,Magnus

  • #4 / Nov 08, 2012 1:14pm

    glenndavisgroup

    436 posts

    Try something like this:

    {exp:channel:entries….}
    ...some html code or fields etc. here
    
    {exp:search:simple_form channel="TheChannelYouWantToSearch"...}
    <input type="hidden" name="keywords" id="keywords" value="YourKeyWordForYourSearch" />
    <input type="image" name="submit" id="submit" src="{banner_bild}" />
    {/exp:search:simple_form}
    
    {/exp:channel:entries}

    All you need to do above is change the value for the keywords hidden field with the search word you want to search for. I hope that helps.

    Thank you,

    Mike

  • #5 / Nov 08, 2012 2:36pm

    Shane Eckert

    7174 posts

    Hey Magnusvb,

    Does Mike’s suggestion work for you?

    Please let us know!

    Cheers,

  • #6 / Nov 09, 2012 1:21am

    Magnusvb

    57 posts

    Hi Mike (and Shane)
    I’m sorry, but I don’t think I understand :red:

    Well, I added the code to the page for the banners (not the search or result page):

    <div>
    {exp:channel:entries
        channel="banner"
        status="open|riks"
        dynamic="no"
      }
      <a href="http://{banner_lank}">{banner_bild}</a>
      
    
      
      {exp:search:simple_form channel="min_skola"} // this is the channel for the search
      <input  name="keywords" id="keywords" value="{banner_kommun}" /> // holds the same value as a custom filed in channel min_skola
      <input type="image" name="submit" id="submit" src="{banner_bild}" />
      {/exp:search:simple_form}
      
      {/exp:channel:entries}
    </div>

    Clicking the banner gives “No result”. Maybe I did not explained it right :red: So a recapitulation is like this:

    #1. You do a search on this page: http://skola.studioalice.se/min_skola (search channel is min_skola)

    {exp:search:simple_form channel="min_skola" status="open" search_in="everywhere" where="exact" result_page="min_skola/resultat"}
                <select name="keywords">
                   <option value="" selected="selected">- Välj kommun -</option>
                   {exp:query sql="SELECT DISTINCT `field_id_35` AS skola_kommun FROM `exp_channel_data` WHERE `field_id_35`<>'' ORDER BY `field_id_35`"}
                    <option value="{skola_kommun}">{skola_kommun}</option>
                   {/exp:query}
                   
                  </select>
                  <input type="submit" value="Sök" class="small round green button">
                  <input type="hidden" name="orderby" value="title" />
                  <input type="hidden" name="sort_order" value="asc" />
              {/exp:search:simple_form}


    #2. Banners are added through admin and with a custom field for the link (to the result page). Banners also have it’s own channel “banners”

    Regards, Magnus

     

  • #7 / Nov 09, 2012 10:02am

    glenndavisgroup

    436 posts

    Hi Magnus,

    How do you attach the banners to the keywords you have in the dropdown? Do you store them in the banner channel or are those keywords categories?

    Thank you,

    Mike

  • #8 / Nov 09, 2012 10:58am

    Magnusvb

    57 posts

    Hi Mike
    In the banner channel I have a custom text field for the search keyword, AND also have added to the default status group: “kommun” (like city) and “riks” (like country). Thats because some banners will only be shown after you have done a search, and they are connected to a specific city.

    The sql query is so that each city only appears once in the drop down menu (otherwise it appears once for each entry).

    Have a great day!
    Magnus

  • #9 / Nov 09, 2012 11:13am

    glenndavisgroup

    436 posts

    Ok I see. Try this:

    <div>
    {exp:channel:entries
        channel="banner"
        status="open|riks"
        dynamic="no"
      }
      <a href="http://{banner_lank}">{banner_bild}</a>
      
    
      
      {exp:search:simple_form channel="min_skola" status="open" search_in="everywhere" where="exact" result_page="min_skola/resultat" form_id="frmSearch{entry_id}" name="frmSearch{entry_id}"} // this is the channel for the search
      <input type="hidden" name="keywords" id="keywords" value="{banner_kommun}" /> // holds the same value as a custom filed in channel min_skola
      <input type="image" name="submit" id="submit" src="{banner_bild}" />
      {/exp:search:simple_form}
      
    {/exp:channel:entries}
    </div>

    Let me know how that works for you.

    Mike

  • #10 / Nov 10, 2012 1:50am

    Magnusvb

    57 posts

    Yay!
    Mike, that worked great 😊
    Many thanks for your help and patients.

    // Magnus

  • #11 / Nov 12, 2012 12:47pm

    Shane Eckert

    7174 posts

    Hey Magnusvb,

    I am glad that Mike was able to help you out! That’s great.

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases