Jump to content

davo

Members
  • Posts

    283
  • Joined

  • Last visited

Everything posted by davo

  1. Diogo, you're a star. It worked. The result: http://dmc.dudmc.com/about-du-and-dmcs/what-is-a-dmc-destination-management-company/
  2. Diogo: Thanks, I'll give that a try this evening. If that doesn't work, maybe I should go about this another way: loop through the regions and in every iteration of the loop, loop through child pages. Macrura: Good guess. Yes, it's bootstrap 3. Laziness stopped the opening ul tags. But, I should be able to insert them along with my opening closing div col tags yes? I was trying to work it out with the following; list total pages, divide it by 3 for my 3 columns. Use ceil to round it up. When the counter reaches my column limit close the div and start again. If there are no more rows, close the div. I thought I had new region sorted?
  3. I'm trying to sort my list out below, alphabetically by the title of the parent item, but my method is resulting in an error. Could someone suggest what is wrong with the code below please. function dmc_list(){ $dmcs = wire('pages')->find("template=dmc"); $dmcs->sort("$dmc->parent->title"); echo"<div class='row'>"; $dmc_total = count($dmcs); $column_total = $dmc_total / 3; $column_ceiling = ceil($column_total); $dmc_count = 0; echo "<div class='container'>"; foreach($dmcs as $dmc){ if((count($dmcs)>0) && ($dmc_count==0)) { echo "<div class='col-md-4'>";} $dmc_count ++; $region = $dmc->parent->title; if($region !== $new_region) { echo "<li class='list-group-item list-group-item-info'><b>{$region}</b></li>";} $new_region = $dmc->parent->title; echo "<li> $dmc->title {$region}</li>"; if($dmc_count == $column_ceiling){ echo "</div>"; $dmc_count = 0; } if(count($dmcs) == 0) { echo "</div>"; } } echo "</div>"; } There's also a flaw in my logic here somewhere as the last column holds more items than the others...
  4. Other people more experienced with storage than me always poo poo'd my rsync job and swore by glusterfs
  5. No, it was with a joomla site. I handled the assets etc using rsync to mirror assets etc. I assume the same would work for pw? This did of course cause an issue when the original site came back online. What I tended to do was hard code a subtle difference into the backup site for the client to tell there was an issue so the client would know not to start making changes or they'd be lost when it reverted back.
  6. DNS made easy is the service I use. It's just a couple of quid a month but's is worth it for peace of mind. They provide a service that looks to your site to find a pre designated page with a string in it. In my case the page is called siteup.php, from memory it has a one line entry echo 'siteup'; the monitoring service just checks for that page once a minute and when it can't find it for whatever reason, it simply changes the DNS entry to the new server. It can also do a tertiary server should the second server fail. It keeps monitoring and when it finds siteup.php switches it back with short ttl settings. If I'm being super efficient I set up SQL replication. http://www.howtoforge.com/mysql_database_replication
  7. For important clients I use dns failover. If the monitoring service can't make contact with the UP script on the site then failover switches dns to another server (in my garage!) Then when it comes back online it switches back again. The switch normally takes about 60 seconds. For not such important sites I use cloudflare.
  8. 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>";} ;}
  9. I'm using PAGE EDIT PER USER to control access to pages for editing. Is there and easy way to call all pages that the current user has editing access to? Something like $mypages = $pages->find("iseditable") I can see in the documentation a way to test the current page but nothing as a selector like this.
  10. You could try some thing like this RewriteCond %{REQUEST_URI} !^gallery If it messes things up just delete the line Make sure there are no other htaccess files floating about
  11. Brilliant; 3 days later i have full functionallity... login using ryan's script https://processwire....tor-login-form/ page edit using soma's modal trick https://processwire.com/talk/topic/2382-processwire-setup-and-front-end-editing-made-easy/ access control via http://modules.proce...-edit-per-user/ module and some cool table editing via profields table https://processwire.com/api/modules/profields/table/ 3 days with just a couple of hours a day..
  12. Odd, I thought I posted last night but now can't find it, so apologies if this appears else where. I'd like to use the render function and apply a class to the table using the $options Could you provide an example please.
  13. $page->body .= " <h2>Change password</h2> <form action='./' method='post'> <p> <label>New Password <input type='password' name='pass'></label><br> <label>New Password (confirm) <input type='password' name='pass_confirm'></label> </p> <input type='submit'> </form> <p>Representing {$user->DMC_select->title}</P> <P>user {$DMC_user} {$config->urls->root} page <a class='editpage-inline' href='http://" . $config->urls->root . $config->urls->admin . "page/edit/?id={$venue_page}&modal=1'>Edit Venue listing</a> </P> <p><a href='/portal/logout/'>Logout</a></p> "; When this is rendered the $config->urls->root doesn't appear, yet the admin part does. Any idea where I have gone wrong?
  14. Thank you. Login page created from Ryan's example used: https://processwire.com/talk/topic/1716-integrating-a-member-visitor-login-form/ StArted looking at those two modules. Ta
  15. I've been working on a fairly large project which is a single company that represents events and trips run by partner agencies around the world. To sum up, every partner agency has it's own page that is maintained by the representation company. There's also plenty of tools around the site all of which link to the partner agencies such as photos and video galleries. My next stage of the project is to create a number of services that are to be maintained by the partner agencies. These might be hotels or special deals they are offering, or current flight to hotel transfer rates. Really I'm just after some guidance before I commence this stage as I wish I'd done that prior to starting other areas of the project. The issue I can see that I need to addresss are: A log in area for the partner agencies A way of controlling security for what they can each do; I wouldn't want one partner agency being able to control another's page.. oh no! I also need some thought around how to actually structure the data. with regards to the last point, I've had a look at the profields - tables module and on first look it seems to be just the thing. Thoughts, suggestions and ideas welcome (on the understanding that you'll know I'll come back to you another ) David
  16. Cracked it i think.... i'm sure someone will know a much smarter way though <?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. $matches = $pages->find("title|body|DMCcontact_Country~=$q, template=dmc, limit=50"); $count = count($matches); if($count) { if(!$config->ajax){$out .= "<h2>Found $count pages matching your query:</h2>";} $out.= "<ul class='nav'>"; foreach($matches as $m) { $out .= "<li><p><a href='{$m->url}'>{$m->title}</a><br />{$m->DMCcontact_Country}</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 country name</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' value='<?php echo htmlentities($input->whitelist('q'), ENT_QUOTES, 'UTF-8'); ?>' /> <button type='submit' id='search_submit'>Search</button> </form> </div> </div> </div> <?php echo $out; if(!$config->ajax) include("./dmcfooter.inc");
  17. Almost got there; So I get what's happenning. The page posts back to itself and also displays itself in the pop up, minus the header and footer if there is an ajax call. I'm just trying to work out how to also exclude the search and other text if ajax is there. Maybe it's just too late at night... <?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. $matches = $pages->find("title|body|DMCcontact_Country~=$q, template=dmc, limit=50"); $count = count($matches); if($count) { $out .= "<h2>Found $count pages matching your query:</h2>" . "<ul class='nav'>"; foreach($matches as $m) { $out .= "<li><p><a href='{$m->url}'>{$m->title}</a><br />{$m->DMCcontact_Country}</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"> <h2>Please enter a country name</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' value='<?php echo htmlentities($input->whitelist('q'), ENT_QUOTES, 'UTF-8'); ?>' /> <button type='submit' id='search_submit'>Search</button> </form> </div> </div> </div> <?php echo $out; if(!$config->ajax) include("./dmcfooter.inc");
  18. I've been trying to get this module to work with my bastardised search template. I'm not sure if i've written it correctly as when it performs the ajax search, it creates a second search form. Any help would be much appreciated.: <?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 sidebar fields for our query text. // Limit the results to 50 pages. // Exclude results that use the 'admin' template. $matches = $pages->find("title|body|sidebar~=$q, template=dmc, limit=50"); $count = count($matches); if($count) { $out .= "<h2>Found $count pages matching your query:</h2>" . "<ul class='nav'>"; foreach($matches as $m) { $out .= "<li><p><a href='{$m->url}'>{$m->title}</a><br />{$m->DMCcontact_Country}</p></li>"; } $out .= "</ul>"; } else { $out .= "<h2>Sorry, no results were found.</h2>"; } } else { $out .= "<h2>Please enter a search term in the search box (upper right corner)</h2> "; } // 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"); echo $out; ?> <form id='my_search_form' action='<?php echo $config->urls->root?>dmc-search/' method='get'> <input type='text' name='q' id='my_search_query' value='<?php echo htmlentities($input->whitelist('q'), ENT_QUOTES, 'UTF-8'); ?>' /> <button type='submit' id='search_submit'>Search</button> </form> <?php if(!$config->ajax) include("./dmcfooter.inc"); http://dmc.dudmc.com/dmc-search/
  19. Good point about the shortened variable. I noticed it myself after I'd posted and questioned my own daft coding. Unfortunately nulls can't be zeros because I'm not the person inputting page and not all fields on all pages are complete.
  20. ah yes... Makes sense now I think. Because != is not equal to and !== is not equal and not the same type, and 0 is effectively empty. ( I think)! Cheers This latest project is a real learning curve; steep but a fun climb!
  21. I'm using the following code to test if average flying time is less than 6 hours and is not blank. This seems to work until I test it with an integer of 0. Surely, 0 is less than 6? $farflung = ""; $airport = $page->DMC_select->DMCstats_Airports->first(); $flying_time = $page->DMC_select->DMC_Average_Flying_Time_hours; if($page->DMC_select->DMC_Average_Flying_Time_hours > 1) { $plural = "s";} if(($page->DMC_select->DMC_Average_Flying_Time_hours < 6) && ($page->DMC_select->DMC_Average_Flying_Time_hours != "")) { $flying_message .= "With the average flight from a UK airport to {$airport->title} ({$country}) at just {$flying_time} hour{$plural} this is an ideal short haul destination."; }else{ $farflung = "far flung {$page->DMC_select->DMC_Average_Flying_Time_hours}";}
  22. Thank you, using the name field with %= seems to return the correct results now. Thanks
  23. Thank you. I'm almost there using this: $english = $pages->get("template=language, title*=English|english"); if(($page->DMC_select->DMCstats_Language > 0 ) && ($page->DMC_select->DMCstats_Language->has($english))) { $flying_message .= "English is one of the native languages of $country.";} This works if the selected language page 'has' English. Sadly, the person inputting the pages rather than reusing the exisiting values has done a shortcut by rather than adding English on one entry and then French on the next, they've created a single entry like this: "English, French". They've done this quite a few times. So I've got some data entries to clean up, but in the mean time I thought i'd use the selector as i've done above.. "title*=English"; hoping that it would match any with English in the title regardless of other mess surrounding it. But it doesn't seem to bring back any results unless it exclusively has English in the title. Have I used this selector incorrectly or misunderstood it's use? Thanks
×
×
  • Create New...