-
Posts
283 -
Joined
-
Last visited
Community Answers
-
davo's post in Search with spaces was marked as the answer
got there in the end
<?php /** * Search template * */ $out = ''; if($q = $sanitizer->selectorValue($input->get->q)) { // Send our sanitized query 'q' variable to the whitelist where it will be // picked up and echoed in the search box by the head.inc file. $input->whitelist('q', $q); // Search the title, body and country fields for our query text. // Limit the results to 50 pages. // Exclude results that use the 'admin' template. // load my directed search results table $q = htmlentities($q); $keywords = preg_split("/[\s-]+/", $q); $selector = ''; //turn the query to lowercase $q = strtolower($q); //load my list of specific search terms $dictionary_words = $pages->find("template=search_results"); //loop through them to see if the query matches the any of them foreach($dictionary_words as $word){ //if it matches create the selector if($word->title==$q){ $value = htmlentities($word->search_result); $selector = "id=" . $value . ", " ;} } //catch usa if ($q == "usa") { $selector = "parent=1065, "; } //if it didnt match up break the term up if($selector==""){ foreach($keywords as $kw){ $selector .= "Meta_keywords|DMCcontact_Country|DMCcontact_Address_2|DMC_Email~='$kw', "; } } $selector .= "template=dmc, limit=50"; // echo $selector; $matches = $pages->find($selector); // $matches = $pages->find("Meta_keywords|DMCcontact_Country|DMCcontact_Address_2|DMC_Email~=$q, template=dmc, limit=50"); $count = count($matches); if($count) { if(!$config->ajax){$out .= "<h2>Found $count DMC matching your query:</h2>";} $out.= "<ul class='nav'>"; foreach($matches as $m) { if($m->DMC_represented==1){$rep="<span class='glyphicon glyphicon-star-empty'></span>"; $out .= "<li data-toggle='tooltip' data-placement='top' title='{$m->title} is a partner DMC of destinations UNLIMITED. Click the link for their full profile'><p><a href='{$m->url}'>{$rep} Full Partner - {$m->title} - Representing {$m->DMC_country_represented->title}</a></p></li>";}else{$rep=""; $out .= "<li data-toggle='tooltip' data-placement='top' title='{$m->title} are not represented by destinations UNLIMITED therefore a suggestion only' id='nonrep' ><p>{$m->title} - Representing {$m->DMC_country_represented->title} - {$m->DMC_Email} </a></p></li>";} } $out .= "</ul>"; } else { $out .= "<h2>Sorry, no results were found.</h2>"; } } else { $out .= " "; } // Note that we stored our output in $out before printing it because we wanted to execute // the search before including the header template. This is because the header template // displays the current search query in the search box (via the $input->whitelist) and // we wanted to make sure we had that setup before including the header template. if(!$config->ajax) include("./dmcheader.inc"); ?> <div class="container"> <div class"row"> <div class="col-md-6"> <?php if(!$config->ajax){ echo "<h2>Please enter a destination</h2>";} ?> <form id='my_search_form' action='<?php echo $config->urls->root?>dmc-search/' method='get'> <input type='text' name='q' id='my_search_query' class='form-control' value='<?php echo htmlentities($input->whitelist('q'), ENT_QUOTES, 'UTF-8'); ?>' /> <button type='submit' id='search_submit'>Search</button> </form> <?php echo "$out"; ?> </div> </div> </div> <script type="text/javascript"> $(document).ready(function(){ $("[data-toggle=tooltip]").tooltip({ placement: 'right'}); }); </script> <?php if(!$config->ajax) include("./dmcfooter.inc"); -
davo's post in using a multi value form field to search page array was marked as the answer
OK, I think I got there in the end. I think it's still messy but I it does seem to work.
For info of anyone that wants to do the same:
$hours_flight = $input->get->hours_flight; // this comes from the slide $time_difference = $input->get->time_difference; // this comes from the other slider $specialism = $input->get->specialism; // this comes from a form builder using ASM select if($specialism){ $special_selector = ", DMCstats_Specialise_In="; foreach ($specialism as $special) { $special_selector = $special_selector . $special . "|"; } $special_selector = rtrim($special_selector, "|");}else{ $special_selector = "";} ?> $negative_time = $time_difference - ($time_difference * 2); // time difference uses a signed integer $matches = $pages->find("template=dmc, DMC_Average_Flying_Time_hours<=$hours_flight, DMC_Average_Flying_Time_hours!='', DMCstats_GMT<=$time_difference, DMCstats_GMT>=$negative_time $special_selector"); // im after all pages that are less than or equal to the flight time, less that time difference and greater than the negative time difference which renders me a page like this:
http://www.dudmc.com/dmc-hunter/
...plus there's something wrong with my divs, but that's for another day.
-
davo's post in if user has role then do some styling was marked as the answer
Thanks anyway. Got there like this in the end.. think it works:)
<table class="table table-striped"> <thead> <tr> <th>Visit Date</th> <th>User Roles</th> <th>User Name</th> <th>Page ID </th> <th>DMC Page</th> <th>Country</th> </tr> </thead> <tbody> <?php $durole = "du"; // this is the role that I want highlighted in the rows $agentrole = "agent"; foreach($page->visit_log as $visit_log_item) { $username = $users->get($visit_log_item->user_id) ; $pagename = $pages->get($visit_log_item->page_id); if ($username->hasRole($durole)) { $row = "info"; } elseif ($username->hasRole($agentrole)) { $row = "danger" ;} // if the user has the durole which is called du the the table row should be success else info echo "<tr class='$row'>"; echo "<td>$visit_log_item->date</td>"; echo "<td>{$username->roles}</td>"; echo "<td>{$username->name}</td>"; echo "<td>$visit_log_item->page_id</td>"; echo "<td>{$pagename->name}</td>"; echo "<td>{$pagename->DMC_country_represented->name}</td>"; echo "</tr>"; $row = "active"; } ?> </tbody> </table> -
davo's post in Find editable pages for current user was marked as the answer
Got there in the end I think; like this:
foreach ($myeditpages as $myeditpage) {
if($myeditpage->editable()) { $page->editor .="<P><a class='editpage-inline' href='{$myeditpage->url}'>View {$myeditpage->title} </a></p>";}
;}
-
davo's post in ProcessGetVideoThumbs upgrade issue was marked as the answer
Thanks Soma
I had a look in the /site/modules directory and removed the newly installed module.
After that, the site started functioning again properly.
I have a suspicion this is something to do with something that Adrian mentioned. He said that when i downloaded the module from git hub it added -master to the module name. When i used the autoupgrade service for the module it installed it without this suffix on.
I didn't know about the debug mode so thanks.
I'll move this topic back to the module forum for further advice on how to upgrade the module.
Thanks
-
davo's post in no results from post was marked as the answer
I forgot to name the field... oops.
read on by...