ThemeShaper Forums » Thematic

[closed]

Unified Search and WP E-Commerce

(6 posts)
  • Started 4 years ago by joshuaiz
  • Latest reply from jonnycj
  • This topic is not resolved
  1. joshuaiz
    Member

    I'm using a child theme and have wp e-commerce installed. As you may or may not know, the normal WP search does not search for your products in wp e-commerce and the wpec *only* searches the products.

    There is a plugin called Simple Unified Search for WP E-Commerce and the instructions give this bit of code to add to modify the search loop:

    <?php if (have_posts()) : ?>
          <?php while (have_posts()) : the_post(); ?>
              <?php if (!psp_isProduct($post)) : ?>
                  <!-- Normal post display code goes here -->
                  ...
              <?php else : ?>
                  <!-- Here goes product display code -->
                  <a>">
                      <img src="<?php psp_productImageName($post); ?>" width="56"
                           alt="<?php psp_productName($post); ?>"
                           title="<?php psp_productName($post); ?>" />
                  </a>
                  <a>">
                      <?php psp_productName($post); ?></a>
                      On product category
                      <a>">
                          <?php psp_productCategory($post); ?></a>
                  <?php psp_productData($post); ?>
              <?php endif; ?>
          <?php endwhile; ?>
      <?php else : ?>
          Not Found
      <?php endif; ?>

    My question is, should I wrap this in a new search function and put it in the functions.php file of my child theme? How would I do this? Otherwise, how would I modify the search loop in Thematic to allow for this modification?

    FYI - I've tried Search Unleashed and I got an error on index with one of the wp e-commerce dynamically generated pages...

    I'm still a bit new to this so could really appreciate the help.

    J

    Posted 4 years ago #
  2. Hi joshuaiz,

    Look into thematic/library/extensions/content-extensions.php for the contents of thematic_search_loop

    You'll want to remove it in your child theme's functions.php with:

    function child_remove_searchloop() {
         remove_action('thematic_searchloop','thematic_search_loop');
    }
    add_action('init','child_remove_searchloop');

    Next you'll want to rebuild you're version of it:

    function child_create_searchloop() {
         // add your modified loop here
    }
    add_action('thematic_searchloop','child_create_searchloop');

    -Gene

    Posted 4 years ago #
  3. joshuaiz
    Member

    Thanks Gene...

    I added the function to remove the thematic search loop and then added the function to create my search loop but I'm getting a syntax error...I just copied and pasted what was in the plugin documentation but I don't know enough to figure out what's wrong with the code:

    function child_create_searchloop() {
         // add your modified loop here
    
         <?php if (have_posts()) : ?>
         <?php while (have_posts()) : the_post(); ?>
             <?php if (!psp_isProduct($post)) : ?>
                 <!-- Normal post display code goes here -->
    
             <?php else : ?>
                 <!-- Here goes product display code -->
                 <a>">
          <img src="<?php psp_productImageName($post); ?>" width="56"
               alt="<?php psp_productName($post); ?>"
               title="<?php psp_productName($post); ?>" />
      </a>
             <?php endif; ?>
         <?php endwhile; ?>
     <?php else : ?>
         Not Found
     <?php endif; ?>
    
    }
    add_action('thematic_searchloop','child_create_searchloop');

    I'm also not sure what goes into the 'Normal post display code' area...would I just insert the code that's in the thematic searchloop in content-extensions.php?

    This is the only bit I'm having a lot of trouble with on the site I'm working on. If I can get this unified search working, I'm golden.
    J

    Posted 4 years ago #
  4. Try this:

    function child_remove_searchloop() {
         remove_action('thematic_searchloop','thematic_search_loop');
    }
    add_action('init','child_remove_searchloop');
    
    function child_create_searchloop() {
    	// add your modified loop here
    
    	if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<?php if (function_exists(psp_isProduct) && (psp_isProduct($post)) ) { ?>
    			<!-- Here goes product display code -->
    			<a href="#">
          			<img src="<?php psp_productImageName($post); ?>" width="56"
          				alt="<?php psp_productName($post); ?>"
          				title="<?php psp_productName($post); ?>" />
      			</a>
    		<?php } else { ?>
    			<!-- Normal post display code goes here -->
    			<div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
    				<?php thematic_postheader(); ?>
    				<div class="entry-content">
    					<?php thematic_content(); ?>
    				</div>
    				<?php thematic_postfooter(); ?>
    			</div><!-- .post -->
    		<?php } ?>
    	  <?php endwhile;?>
    	<?php endif;
    }
    add_action('thematic_searchloop','child_create_searchloop');

    I think this addresses what you're trying to do.

    -Gene

    Posted 4 years ago #
  5. joshuaiz
    Member

    Thanks Gene - you are awesome. Unfortunately, the Unified Search Plugin is not working...

    With this function, and without the plugin activated the search works as it did before but as soon as I activated the Unified Search for WP E- Commerce plugin (which is not really a full fledged plugin) the search is hosed. I just get blank images with a question mark and the urls don't point to anything.

    Since I've created a page structure that augments the dynamically created pages in wp e-commerce the normal WP search (without the plugin activated) is still grabbing those page titles so it kind of gets people to the products. I can live with this for the time being.

    I just feel like having two search boxes (one for products and one for posts) is a wholly inelegant solution. Hopefully Instinct (the developers of wp e-commerce) will build a unified search into a future version.

    That said, if I could get Search Unleashed working that would solve my problem as well, I get an error related to one of the wp e-commerce functions on index and then the index fails...no one on the getshopped.org forums can figure it out...

    Anyway, thanks for your help!

    J

    Posted 4 years ago #
  6. jonnycj
    Member

    did this get resolved ?

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.