Jump to content

adrian

PW-Moderators
  • Posts

    10,901
  • Joined

  • Last visited

  • Days Won

    348

Everything posted by adrian

  1. No problem. In these sort of cases, for the city field (the one in the theatre template), I like to check: "Allow new pages to be created from field?" at the bottom of the Input tab. This makes it easier for the person adding new theaters to the admin to add a new city if required.
  2. I am not sure how you have things set up, but I would have a page select field that contains all the city names. I guess each theatre would have a city field assigned to it via this field. For generating your select dropdown you could do: echo '<select name="selected_city">'; foreach($pages->get("/cities/")->children() as $city){ echo '<option value="'.$city->name.'">'.$city->title.'</option> } echo '</select>'; Then for your selector for limiting theaters to the selected city you might have something like: $theaters = $pages->get("/theaters/")->children(city=$session->current_city); All written in the browser and untested, but should be close, but again it depends on how your theaters and cities fields/templates are already set up.
  3. If you do it simply with a page refresh, rather than ajax, you can simply do something like the following at the top of the page: if($input->get->selected_city){ $session->current_city = $input->get->selected_city; } else{ $session->current_city = $user->user_city; } You can use the $session->current_city directly in your selector. You can choose get or post for the action for your form depending on whether you want the selected_city passed via the url (good for bookmarking) or not.
  4. Why not set $session->current_city = $user->user_city and then if they choose an alternative from the select box, change it using: $session->current_city = $input->get->selected_city or something like that, depending on how you process the select box.
  5. I would recommend defining a new role called "deletor" with permissions to view, edit. and delete. Then for the appropriate template you simply give the deletor role the ability to edit the page. Should work as you need. For those templates that should be edit only, only check edit for the editor role, not the deletor role as well. Does that make sense?
  6. Or you could use SQL directly like so: $pageIDs = array(); $result = $db->query("SELECT id FROM pages INNER JOIN field_intro ON field_intro.pages_id = pages.id WHERE LENGTH(data)<10"); while($row = $result->fetch_row()) $pageIDs[] = $row[0]; $pageArray = $pages->getById($pageIDs); // $pageArray contains what you want EDIT: If kongondo's assumption is correct that you are just looking for an empty intro field, then his approach is the way to go for sure!
  7. Actually haven't used this myself before, but try: press_exhibition|news_exhibition|press_artist|news_artist=$exhibition_id|$exhibition_id|$exhibition_artist|$exhibition_artist This may not work exactly as you want because it will check if any of the variables are in any of the fields, but depending on your structure and possible options for these fields it might be ok. If not, I think you might have to do multiple selections and combine them like you suggested. Here is an example of combining: http://processwire.com/talk/topic/3055-replicate-mysql-union-with-selectors/?p=30033 In these cases I have actually gone with using standard SQL: http://processwire.com/talk/topic/3053-possible-to-select-modifiedcreated/?p=30093
  8. You can do: press_exhibition=$exhibition_id, news_exhibition=$exhibition_id, press_artist=$exhibition_artist, news_artist=$exhibition_artist Are you looking to replicate "and" or "or" ?
  9. Have you tried stripping your template code down to the basic example on the github page? Basic example: $t = $modules->get('MarkupTwitterFeed'); echo $t->render();
  10. Quick glance - do you need to have: $first_page = $siblings->first()->id
  11. Just to clarify - I am not having any problems with the new version of the module working at all. My comments were strictly related to upgrading and the link on the GitHub page. Can you provide anymore info on why the new module isn't working for. No output, errors, what? I was getting errors initially because I was using: $t = new MarkupTwitterFeed(); but switching to: $t = $modules->get('MarkupTwitterFeed'); fixed everything. Does that help?
  12. I went to update to v2 today and noticed that it is not showing up in the modules manager. Thought I'd uninstall and see if that helped, but got this error: DirectoryIterator::__construct(/xxx/site/assets/cache/MarkupTwitterFeed/): failed to open dir: No such file or directory The directory doesn't exist - not sure why. Anyway, manual upgrade seems to be fine. Another thing - the link from the Github page: "To obtain these, create a new Twitter application at: https://dev.twitter.com/apps." is broken!
  13. I agree with most of the opinions here - it really is personal preference. So long as it is clear, well indented and commented, it doesn't really matter. There are some conventions which make sense, but there are no definitive rules. I prefer Ryan's code block above, but I actually prefer to echo with single quotes and use double quotes inside since this is what the HTML output looks like. I guess the downside to my approach is the need to: ' . $variable . ' but for some reason that seems better to me - don't really know why. I guess Ryan's combo is probably the simplest - maybe I should switch - hard to break old habits
  14. Congrats on getting things working - feels good doesn't it I am guessing the sorting issue you are having is to do with the field type you are using to store the photo_resolution. If you are using text, try switching it to Integer and I think that will solve your problem. One thing to note - you should make sure you sanitize all the get variables. Read this to learn more about your options: http://processwire.com/api/variables/sanitizer/
  15. You don't need the splitting technique with multiple selects. That was only if you wanted to use just the one select. I am not really sure where you are still having troubles at this point. Any chance you can show us the site? I am heading out for the day now. Hopefully someone else will pick up and help you. One more thing you will want to do is get the select options to be selected once the form has submitted so the user can see what they selected and change from there, rather than starting from scratch. For this you'll want to echo selected="selected" for the appropriate option in your form - similar to how it is done for the keywords text input field. Good luck! You really are close
  16. That option seems limiting to me - now the user can only choose one of the ways to sort, rather than a grid of options. If they are in separate selects then the user can search all the combos. Do you not want that flexibility for some reason? But if you do want to do that, I guess you could make the option values things like: resolution-desc and resolution-asc and then in the if statements, you could split these. Something like: $search_order = strstr($input->get->sort_photos, '-'); // gets order, eg asc $search_type = str_replace($search_order, '', $input->get->sort_photos); // gets search type, eg resolution Does that make sense?
  17. I'd also really recommend the selector test tool: http://modules.processwire.com/modules/process-selector-test/
  18. As a self help tool, try echo'ing $selector and see how that changes between your first and subsequent searches. eg: echo 'selector string: ' . $selector;
  19. Sorry, my example wasn't supposed to include the ordering - it was just an example for the keyword search. If that is working, then it shouldn't be hard to add the sort by those field options. It looks like your additions are on the right track, but you might want to take out the template=photo bit. If you are only searching the children of the photos main page, you won't need this. If you do want to keep it in, then define it first $selector = "template=photo" and then when you append other parts: if($input->get->camera_resolution == 'asc') { $selector .= "sort=camera_model,"; } elseif($input->get->camera_resolution == 'desc'){ $selector .= "sort=-camera_model,"; } Then in your form you need the select options to have values like: <select name="camera_resolution" id="camera_resolution"> <option value="desc">Highest to low</option> <option value="asc">Lowest to high</option> </select>
  20. I think you have the right idea with the example you showed above, but a few things: At the end of your <form tag you are using the php close tag (?>) twice. You want something like: action="<?php echo $config->urls->root; ?>browse/" When you are using PHP and things aren't working, be sure to view the source of the rendered HTML page to confirm it is generating what you think it is. Also make sure you are getting your PHP errors generated somewhere, either on the page or in a log file. Not sure how this is set up as it can depend on the settings on your host. If you don't see them, ask them and/or google turn on php error reporting. Also, turn on debug on PW config. You should define $selector once as $selector = ''; before you start appending parts to it. Not a fatal error, but good practice. You are trying to use the $selector before you have generated it Try this: <?php if($input->get->keywords) { $value = $sanitizer->text($input->get->keywords); $selector .= "title|body%=$value, "; $summary["keywords"] = $sanitizer->entities($value); $input->whitelist('keywords', $value); } $images = $page->children($selector); foreach($images as $image) { echo '<img src="'.$image->url.'" alt="'.$image->title.'" title="'.$image->title.'" />'; } ?> <h1>Browse photos</h1> <form id="photo_search" method="get" action="action="./""> <p> <label for='search_keywords'>Keywords</label> <input type='text' name='keywords' id='search_keywords' value='<?php if($input->whitelist->keywords) echo $sanitizer->entities($input->whitelist->keywords); ?>' /> </p> <p> <input type="submit" id="search_submit" name="submit" value="Find" /> </p> </form> Because I am still not sure of how your pages are structured, this may not work. But if as you say, $photos = $pages->find("template=photo, sort=camera_model"); worked, then maybe you could replace the selector line I have above with: $photos = $pages->find($selector); If you decide to follow the second link that kongondo mentions above, be sure to read through to the end of the thread. I made a few changes to that code to improve it, thanks to some suggestions by Soma. Honestly, I think in your case, building a custom form like we are doing here will be a better approach. Let us know how you go.
  21. The trick is to build up a string variable eg. $selector, based on the options chosen by the user and using that variable as part of something like: $images = $page->children($selector); This assumes of course that all your images are child pages of the main gallery page. You'll probably want $selector to end up being something like: sort=-camera_model, sort=resolution, sort=-size The way to build $selector can be seen in the Skyscraper's search.php file. For example, this section: if($input->get->keywords) { $value = $sanitizer->selectorValue($input->get->keywords); $selector .= "title|body%=$value, "; $summary["keywords"] = $sanitizer->entities($value); $input->whitelist('keywords', $value); } Each section like this appends more component parts to the $selector string using the '.=' notation. The $input->get->keywords refers to a variable passed from your form using the GET method. You could of course also use POST. GET will put the variables in the URL like ?keywords=word& etc. This is useful for allowing a user to bookmark or share a query link. I am not exactly sure your plans for the resolution and size selects - sounds like you want to offer sorting highest to lowest and lowest to highest? If so, you can build your selector using sort options. Take a look at the sort options on this page: http://processwire.com/api/selectors/ Once you have defined your $selector and searched and sorted the children with it, you can simply foreach through the images: foreach($images as $image){ echo $image->url ...... //etc } Hope that helps.
  22. It really is great having such a powerful system that also allows for very rapid development of simple sites I really want to thank you for pointing out fontello. I have used font awesome before, but this is an amazing looking tool that takes things to a new level of flexibility!
  23. But kongondo might have a better answer for finding text within a field. I really depends on how you'd be using it. Whether you want to find pages with that text (his example), or whether you want to do something different with the output in your template depending on whether that text exists or not when you are displaying a page (my example). Hopefully one of us has hit the mark
  24. Hi Jamie, and welcome. Have you seen the cheatsheet yet: http://cheatsheet.processwire.com/ I am not sure if you are looking to check the template of a specific page, or find a sibling with a specific template. This should help: if($page->template == 'template_name'){ As for checking is a textarea (or any other field contains a specific piece of text)if (strpos($page->textareafieldname, 'specifictext') !== FALSE) echo 'Found';else echo "Not found"; Hope that helps.
×
×
  • Create New...