Forum Discussion

iftomkins's avatar
11 years ago

How do I test for the "interaction style" of a page I'm on?

I created a custom search form for mobile which searches all ideas boards. I want to show this form only on category pages which have the interaction style of "idea".   The url contains this inform...
  • iftomkins's avatar
    iftomkins
    11 years ago

    Update: I gave up and attacked it with Javascript. Solved.

     

    Rant: I've had to do this alot with Lithium. I'm pretty disappointed that what you can do with freemarker is limited, and what you can do is not simple usually. Even a simple thing, like writing a conditional statement based on what page/category the user is currently viewing, is very difficult. I've presented many of these headscratchers to KaelaC  at Lithium, and she's great and can usually figure them out, but even for her, it's a little work, and we are often asked to sign new contracts to get Lithium's help to complete work as simple as this thread's subject: how to test what page you're currently on.

     

    Here's the full solution I used:

    1. Hide the form with CSS

    2. If URL contains interaction-style/idea, show the form

    3. The search form searches all ideas boards, and deposits the user on the mobile search page

     

    <style>

    #form_mobileIdeas {

        display: none;

    }

    </style>

     

    <#-- Search form that searches all ideas boards. Created for Mobile because out-of-the-box component did not exist. -->
    <@liaAddScript>
    LITHIUM.jQuery(document).ready(function() {
    //Show ideas search form on ideas category pages, hidden by default in CSS
        var url = window.location.href;
        if(url.indexOf("interaction-style/idea") > -1) {
            LITHIUM.jQuery("#form_mobileIdeas").show();
        }
    });
    </@liaAddScript>

    <form class="lia-form lia-form-inline SearchForm" action="/t5/forums/searchpage/tab/message" method="get" id="form_mobileIdeas" name="form_mobileIdeas">
        <input type="hidden" name="include_ideas" value="true" />
        <input title="Search" class="lia-form-type-text search-input" value="" id="mobileIdeasSearch" name="q" type="text" autocomplete="off">
        <span class="lia-button-wrapper lia-button-wrapper-secondary lia-button-wrapper-searchForm-action">
            <input class="lia-button lia-button-secondary lia-button-searchForm-action" value="Search Ideas" id="mobileIdeasSubmit" type="submit">
        </span>
    </form>