• Modyssee

    (@modyssee)


    Hello

    I have a job board theme and it has 2 differents type of posts, one is “job_listing” and the other one is “resume”

    I have one form for job_listing sidebar and a different form for resume sidebar.
    Both work fine BUT my problem, is that, when we click on “search” on form in resume sidebar, even if it funds results, it replace the form of resumes sidebar with the form from job_listing.

    So i think the best way to solve this will be to conditionally display the search form based on the post type currently displayed, you know?
    But i don’t know how to do it… that’s why i need help 🙂

    Thanks in advance

    http://wordpress.org/extend/plugins/advance-wp-query-search-filter/

Viewing 15 replies - 1 through 15 (of 19 total)
  • Plugin Author TC.K

    (@wp_dummy)

    Yes, the search form can be conditionally displayed.

    However you will have to edit it in your template, current shortcode doesn’t support that.
    To do it, in your sidebar template :
    <?php
    if(is_search()){
    $type= get_query_var( post_type );
    if(in_array(“job_listing”, $type)){
    echo do_shortcode(‘[awsqf-form id=14]’);//for your job-listing
    }

    if(in_array(“resume”, $type)){
    echo do_shortcode(‘[awsqf-form id=15]’);//for your resume
    }
    }

    /*Note that this is only work for the search/.
    You can add other conditional in here, eg is_page, is_archive etc*/
    ?>

    Thread Starter Modyssee

    (@modyssee)

    Thank you very much for answering so fast. Unfortunately it didn’t did what i was hoping for.

    I don’t know if i explain you more if you could find the answer (i can only do some simple edit, not build codes you know as i’m not a developper)

    I’ll make a first donation if you can solve my problems and a bigger one once my site is launched and i get my first income from it (that would be normal if, thanks to you, i can finalize my website and get income from it, to reward you a bit more for your help).

    I explain the problem.
    I’m using jobroller theme (from appthemes), a job board theme.
    The theme has no advanced search system to search by sidebar, multi selection etc. just a very basic search (if we can even call that a search widget) as you can see on their demo page http://demos.appthemes.com/?theme=jobroller

    So i bought a plugin especially made for that this theme but, i’ve been mislead by the author as he made me believe his widget will do multi selection and multi option search. Results: it was a lie, it doesn’t work well on job_listing search (no multi criteria search like he claimed) and don’t do at all multi select. So i spent 29$ for nothing.

    Then i bought an advanced search plugin on another website, it worked, but i didn’t realize before i buy that it won’t do multi form, so it was useless for me. I spent 19$ for nothing.

    2 days ago, i found on codecanyon a plguin that will do multi form, so i bought it thinking my problems wil lfinally be sovled. It worked for job_listing but not for resumes, so 19$ for nothing.

    Then i found your plugin that does everything i needed. The worst is that i’ve searched on free plugins before buying plugins, and didn’t find anything grrrr.

    My problem is hard for me, but might be simple for a developer like you.

    As i explained you there are 2 post types on jborolelr theme
    > job_listing
    > resume

    On the theme there are specific sidebars, so i add the widget this way:

    1.custom form i created for searching job listing on main sidebar (it displays on homepage) and single job listing sidebar.
    For this part, it works flawlessly after i made some edit in theme thanks to the help of the author one of the plugin i bought, it seems to do the trick for any custom search plugin working with this theme)

    2. custom form i created for searching resumes on resumes sidebar.
    And that’s where i have problems.
    When i make a search, it returns results BUT 3 problems happen:

    a. The display look is not the same as it is with default basic search from theme (or as it was with the search especially made for this theme). It displays in black on not in color and is not “arranged” the same way.
    http://i1316.photobucket.com/albums/t609/Modyssee/default-searc-results-look_zpsf84d1ad8.png > default

    http://i1316.photobucket.com/albums/t609/Modyssee/look-with-custom-search_zps4a03ecde.png > not normal look

    b. when i click on search, i get search results (but not displayed correctly as shown on image above) BUT the resume sidebar is purely replaced by main sidebar, it’s very weird (but when i select a resume to visualize it, the sidebar is the good one (resume sidebar) touhgh, even if when’ill make a new search it will be replaced with main sidebar again (so the one for job listing search).
    That’s why i thought that including a condition like the one you gave me will resolve the problem.

    c. the resumes search, even if the search resume sidebar is displayed should be avaiable only to does who have subscribed. But with a custom widget not especially made for the theme, contrary to what i thought at first, it doesn’t take into account the fact that search resume shouldn’t be accessisble if there’s no subscription/paid pack active you know? So anybody can do the search and get results instead of getting the message “blabla you need to subscribe” once you click on search.

    I think that all the elements/terms can be solved at the same time with conditional stuffs that are in on file of the theme called “resume-search.php” even if it’s made for very basic search, but i’m not a developper so i’m so lost 🙁

    http://pastebin.com/NuMMLHPT > search-resume.php code
    http://pastebin.com/feZvmExG > search.php code (just in case)
    In both files, there are lot of useless code as far as i don’t use the basic search etc. it’s just for pieces of code to make your plugin stop doing the 3 stuffs i mentioned in resume section 🙂

    I’ll greatly appreciate your help 🙂

    Thread Starter Modyssee

    (@modyssee)

    Never mind, i found new problems, so i’m tired and i probably gonna abandon my project.

    Plugin Author TC.K

    (@wp_dummy)

    It’s seem your problem is more on the theme side.

    However, I still give some suggestion on your problem in case you want to continue your project.

    2.a
    Since the plugin use the theme’s search.php template to display the search result. This problem is more likely have something to do with your theme file. Do you have specific template for the plugin generated search result? If so, big possibility is this template that causing this problem.

    2.b
    It’s still conditional problem. Hard to tell what’s going wrong, have to examine your theme to confirm the problem.

    2.c
    Also achievable, by using <?php if ( is_user_logged_in() ) { ... } ?> to check if the user is logged, and using if (current_user_can('****_****') to check the role of the user. This can apply whether want to display the form to non-logged in user.

    After take a glance on search.php and search-resume.php.
    ,you can try add this on the first line (top) in search.php :
    <?php if (isset($_GET['wqsfsubmit']) && $_GET['wqsfsubmit'] == 'Search') : get_template_part('search-resume'); return; endif; ?>
    This maybe can solve problem 2.a (maybe 2.b as well, if you are lucky)

    Thread Starter Modyssee

    (@modyssee)

    Thank you for the help TC.K !

    Actually the code
    <?php if (isset($_GET[‘wqsfsubmit’]) && $_GET[‘wqsfsubmit’] == ‘Search’) : get_template_part(‘search-resume’); return; endif; ?>

    did solved the problem i mentionned of the resume sidebar and resume display! And even much more becausei had discovered a very annying problem (resume search was returning results even with no subscription to this section active, so it even sovled this !) So thank you for that!

    But now when i do a search on the other form (the one i added in main sidebar and singlesidebar (for job listing search) that is different from the resume sidebar form, it does the reverse problem 🙁
    It gives my job listing results the way resumes results look and redirects me to resume section with resume sidebar (error found on sidebar
    Warning: Illegal offset type in isset or empty in wp-includes/post.php on line 1097 ). SO it’s the reverse problem. That’s so weird.
    When there is no active subscription for the user to make resume search, making a job listing search simply rediects to resumes section (no results, no erro message).

    Line 1097 of post.php in wp-includes is if ( empty($wp_post_types[$post_type]) )

    Entire code section is:

    function get_post_type_object( $post_type ) {
    global $wp_post_types;

    if ( empty($wp_post_types[$post_type]) )
    return null;

    return $wp_post_types[$post_type];
    }

    I tried replacing one of the two wqsfsubmit with awqsfsubmit, then resume_search and vice versa, but when there is not the code you gave me, it didn’t work.

    By the way, just for my information, why the code you gave me has “wqsfsubmit” and not “awqsfsubmit” ? i saw awqsf everywhere on your plugin, but no instances of just wqsf.

    Thread Starter Modyssee

    (@modyssee)

    I’m not gonna bother you much “i” found a working solution.

    Main sidebar + single sidebar = form from the plugin i bought on codecanyon

    Resume sidebar = your plugin

    And with the code you gave me It works combined together (whereas i had the same problems with his plugin too)

    Thank you very much!

    I’ll make you a donation as soon as i’m sure i can finish the development (because i’m like cursed, a problem solved, make me discover a new problem)

    Plugin Author TC.K

    (@wp_dummy)

    Hi,
    Glad that you found the solution.
    However, if you still want to use both of the search form, I got another suggestion.
    In the previous answer I forgot that you have two search form. So in order the forms work properly maybe you can try to change the code to this :

    <?php if (isset($_GET['wqsfsubmit']) && $_GET['wqsfsubmit'] == 'Search' && $_GET[formid] =='your resume search form id' ) : get_template_part('search-resume'); return; endif; ?>

    Note that for the $_GET[formid] ==’your resume search form id’, you will need to put your form id into it. This is the identifier for resume search form. Try it, it maybe will solve the job listing search problem.

    Likewise, you can use this formid for the conditionally display the search form in the search result sidebar (as mentioned in the original question of this thread).

    As for the “wqsfsubmit” not “awqsfsubmit”, this is because this plugin is a upgraded version on my previous plugin (which is already discontinued). Some of the code may retained as I forgot to change it. No biggie.

    Thread Starter Modyssee

    (@modyssee)

    I’ll try that right, now thanks again.

    You know, you should sale your plugin on cadecanyon, i bought two plugins like yours before discovering yours, dev on codecanyon make thousands of dollars.

    p.s: on the plugin i bought on codecanyon there’s is a feature that auto submit form (you have the choice to enable it or no) so when you tick box, select something, in real time it filter the results you get, do you think that’s something you could include someday ?

    Thread Starter Modyssee

    (@modyssee)

    Amazing, it works flawlessly with your new code!

    The problem seemed impossible to resolve for me, but the magic of being developer as you is that you see one line as know that’s what will solve the problem 😀

    Plugin Author TC.K

    (@wp_dummy)

    a feature that auto submit form (you have the choice to enable it or no) so when you tick box, select something, in real time it filter the results you get, do you think that’s something you could include someday ?

    It can actually, it is all about javascript ajax. Maybe I will include it into the plugin, just see how busy I am.

    Thread Starter Modyssee

    (@modyssee)

    I’m gonna become crazy, i upgraded to new version of my theme, everything was working super fine, i didn’t change anything special, jsut add taxonomies and after few hours working fine like it was working till now, the problem i had is back, with no reason. Just like that, it worked fine and suddenly same problem.

    I could have thing it’s the new release of my theme, but it worked easily 10 hours on it with no problem before having the same problem as before.

    Thread Starter Modyssee

    (@modyssee)

    the new search.php if it can help (no important difference i think, especially knowing it worked hour “with” the new release

    http://pastebin.com/MQvRBLbF

    Plugin Author TC.K

    (@wp_dummy)

    Weird, does the new theme have search-resume.php?

    Thread Starter Modyssee

    (@modyssee)

    Yes it has (bboth files are at the same palce as it was on previous ersion too)

    http://pastebin.com/P64SeciR (search-resume.php)

    Thread Starter Modyssee

    (@modyssee)

    I turned on the debug mode and debug log and here’s what the log is after i try to search resume and that it gives me the problem:

    http://pastebin.com/C8aVr2M5

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Conditionally display a search form based on post type displayed ?’ is closed to new replies.