THE WEBSITE SAVED SEARCHES PLUGIN - Dec 9th, 2010
|
This handy plugin works in conjunction with the Website Membership plugin and lets your visitors name and save links to their favorite pages to a list, and to manage that list. The plugin is designed to work only if the visitor has a membership account and is logged in, and will only show that visitors list entries.
It’s pretty easy to implement by following the instructions in the included readme file, but as always, there are some details worth noting.
The first thing that I found was that the path listed in the code to be inserted in the head of your viewer for the “websiteSavedSearches.js” assumed that it was to be found in a “plugins/websiteSavedSearches” sub-directory. If this is not your situation, you’ll need to adjust the path.
The next thing was that although the jQuery script called was version 1.3.2, the jQuery script included with CMSB V2.06 is version 1.4.1. For now you’ll have to manually adjust the code so that the versions match.
Note that this <head> code block must be included on every page that uses the “Saved Searches” plugin.
Here’s how I implemented the plugin for the CMSB Cookbook recipe detail page:
Since the “/lib/viewer_functions.php” file was already loaded on that page, all I had to do was insert the previously modified <script> code block just after the <head> tag, and above any other <script> tags:
<!-- saved searches --> <script type="text/javascript" src="/cmsAdmin/plugins/websiteSavedSearches.js"></script> <script type="text/javascript" src="/cmsAdmin/3rdParty/jquery/jquery1.4.1.js"></script> <script type="text/javascript">jQuery.noConflict();</script> <?php $GLOBALS['WSS_SCRIPTS_LOADED'] = true; ?> <!-- /saved searches -->
Then in the body where I wanted to display the “Save”, “Remove” and “View My Saved Searches” page links, I used this code:
NOTES: 1) My “View My Saved Searches” page is called saved_searches.php 2) I added “AndReload” to both of the “onclick” commands as suggested in the readme file, so that the page would automatically reload to show the “Remove This Recipe From My Saved Searches” link after a page was saved. 3) You can remove the class="<?php wss_cssClassFor('add'); ?>" code from the div tags, but don’t remove the style="<?php wss_displayStyleFor('add'); ?>" code, or both links will show on your page.
<div class="<?php wss_cssClassFor('add'); ?>" style="<?php wss_displayStyleFor('add'); ?>"> <a class="special" href="#" onclick="<?php wss_onClickFor('addAndReload'); ?>">Save This Recipe To My "Saved Searches" List</a> </div>
<div class="<?php wss_cssClassFor('remove'); ?>" style="<?php wss_displayStyleFor('remove'); ?>"> <a class="special" href="#" onclick="<?php wss_onClickFor('removeAndReload'); ?>">Remove This Recipe From My "Saved Searches" List</a> </div> <div ><a class="special"href="saved_searches.php" target="_blank"><br /> View My "Saved Searches" List</a></div>
On the saved_searches.php page, since the “/lib/viewer_functions.php” file was loaded, I inserted the following code into the code at the top pf the viewer page:
// load saved searches list($savedSearches, $savedSearchesMetaData) = getRecords(array( 'tableName' => '_website_saved_searches', 'where' => "createdByUserNum = '" .mysql_escape( @$CURRENT_USER['num'] ). "'", 'loadCreatedBy' => false, 'allowSearch' => false, ));
In the <head> section, I added the <script> calls as before:
<!-- saved searches --> <script type="text/javascript" src="/cmsAdmin/plugins/websiteSavedSearches.js"></script> <script type="text/javascript" src="/cmsAdmin/3rdParty/jquery/jquery1.4.1.js"></script> <script type="text/javascript">jQuery.noConflict();</script> <?php $GLOBALS['WSS_SCRIPTS_LOADED'] = true; ?> <!-- /saved searches -->
Then in the body of the page, I inserted the following to show the “Saved Searches” list:
<?php if ($savedSearches): ?> <table width="737" border="0" cellspacing="0" cellpadding="0"><tr> <td width="79%" class="Medium-Text-Bold">Click On An Entry To View</td> <td width="21%" class="Medium-Text-Bold">Delete From List?</td></tr> <?php foreach ($savedSearches as $record): ?> <tr> <td colspan="2"><hr /></td> </tr> <tr> <td > <a class="saved" href="<?php echo $record['url']; ?>"><?php echo htmlspecialchars($record['name']); ?></a></td> <td ><a class="Small-Text-Bold" href="#" onclick="<?php wss_onClickFor('removeAndReload', $record['url']); ?>">Delete Search</a></td> </tr> <?php endforeach ?> </table> <?php else: ?> <div align="center"><span class="Medium-Text-Bold">You haven't saved any searches so far.<br />But when you do, they'll be listed here.</span></div> <?php endif; ?>
I’ve posted a note on the forum about the jQuery version issue, and will update this when I find out more.
|
The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact
Interactive Tools for information on the downloading of the software or the purchasing of licenses.