Jump to content

adrian

PW-Moderators
  • Posts

    11,185
  • Joined

  • Last visited

  • Days Won

    372

Everything posted by adrian

  1. 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();
  2. Quick glance - do you need to have: $first_page = $siblings->first()->id
  3. 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?
  4. 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!
  5. 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
  6. 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/
  7. 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
  8. 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?
  9. I'd also really recommend the selector test tool: http://modules.processwire.com/modules/process-selector-test/
  10. 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;
  11. 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>
  12. 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.
  13. 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.
  14. 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!
  15. 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
  16. 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.
  17. PS, Have a read of this to learn more about image fields: http://processwire.com/api/fieldtypes/images/
  18. As Ozwim eluded to: $page->main_image->getThumb('thumbnail');
  19. This should do it. Replace eq(0) with the number of the image in the main_image field. echo $page->main_image->eq(0)->getThumb('thumbnail');
  20. Hi Raul, Not sure if I completely understand your needs and it sounds like you know what you are doing so I might be missing your point, but is this what you are looking for? <option name="subject" value="subject1" <?php echo ($input->get->subject == 'subject1' ? '' selected="selected"' : ''); ?>></option> I am not sure how you are building the contact form and the select options, but likely you will be generating all of the option lines dynamically via a foreach, or maybe you are letting PW take care of it with something like $form = $modules->get('InputfieldForm');. Maybe something like this would work for you: foreach($subjects as $subject) { $selected = $subject->name == $input->whitelist->subject ? " selected='selected' " : ''; echo "<option$selected value='{$subject->name}'>{$subject->title}</option>"; } Hopefully something there will be of use. If not, let us know in more details exactly what you need to do and I am sure someone can help.
  21. Hey Ryan, The only render call in the template is for the pager. Not using URL segments. No manual pager options. I figured out the problem - I have a form on that page that allows a guest user to submit a new child page (unpublished of course). The form code was setting the page template to that of the child page, which was why $allowPageNum = $this->options['page']->template->allowPageNum; was returning false. Sorry for not figuring this out sooner!
  22. Have you seen this thread: http://processwire.com/talk/topic/3392-emulate-natsort/ The code I mention in the last post worked well for me.
  23. Actually I am curious about that if statement in the module to show the url with ?page=n if allowpagenum is off. What is the scenario where you would want that? Sorry if I am missing something obvious.
  24. Yep, I am talking about the MarkupPagerNav module. I simplified my code down to something that still causes the issue to appear. $results = $page->children('limit=10');$out .= $results->renderPager();I have a few different sections on the site like:training >training-items teaching > teaching-items publications > publication-item These represent the parent and child pages and the template names. Some of them work without page number option being on in the child template and some don't. The code is otherwise identical from what I can see.
×
×
  • Create New...