Jump to content

adrian

PW-Moderators
  • Posts

    11,182
  • Joined

  • Last visited

  • Days Won

    372

Everything posted by adrian

  1. No problem - most of us find that google does a better job searching this forum than the IP.Board search tool. In case you are not familiar with google site search: site:processwire.com/talk "search term"
  2. Is this what you are looking for: http://processwire.com/talk/topic/519-pagelistselect-issue/
  3. Hey Soma - sorry for the confusion - I just wasn't sure if this comment: "Without further consideration on if what you do is really a good way to go building forms" was directed at the approach I had proposed, or Peter's approach to his current problem. Sorry, I don't think I ever saw that post of yours on creating simple forms using the API - I'll have to start sending people to that!
  4. Hey Soma, You've probably noticed that I have been pointing several people to that form code from diogo Are you suggesting that you don't like that approach? It has been working great for me - makes form generation so simple. I am sure Ryan's form builder is amazing, but so far I have been able to do everything I need with this approach. Do you think I should stop suggesting it?
  5. Stolen from the blog profile. This will get all events for the month of May, 2013 $firstDay = strtotime("2013-05-01"); $lastDay = strtotime("+1 month", $firstDay)-1; $events = wire('pages')->find("template=event, date>=$firstDay, date<=$lastDay, sort=-date"); The rest of it is in the archives.php template.
  6. Oh I see - sorry for misunderstanding on the ProForm. I do think you could easily change the layout by using the class attr, but maybe I am still missing your point. Of course if you match the layout in the backend using the Input -> Column Width (to make your 4 columns) - that layout will be mirrored on the front-end using diogo's code. Different CSS styles for the inputfield classes on the front end could easily change the look too. Not sure if this helps or not, but I have also done the following before. Please keep in mind that this is only partial code, but hopefully it gives you an idea of the approach I am talking about. It still relies on the InputfieldForm, but lets you iterate through each field separately. $questions = $page->fields; //Option type fields (select, checkbox, radio etc) if($question->type == 'FieldtypePage'){ $inputfield = $question->getInputfield($page); $options_parent_id = $inputfield->parent_id; $options_parent = $pages->get($options_parent_id); $options = $options_parent->children(); foreach($options as $option){ $form->append($field); } } Maybe someone else has a better approach!
  7. It doesn't require Ryan's pro form module, if that's what you mean. InputfieldForm is part of the PW core. A couple of options for styling the form. You could use jquery, or you can simply add a class to each field as it gets appended to the $form. See bold line below. if ($myfields){ foreach($fields as $f){ // Output all the fields minus the ones listed in the $myfields array // Instead, to output only the fields that are in the array, remove the (!) from the condition if (!in_array($f->name, $myfields)){ $f->attr('class', 'mycssclass'); $form->append($f); } } } Of course you could nest some conditional statements in here to apply different styles to different field types. Does that take care of what you need to do?
  8. Hi Peter, Have have had lots of success using this code from diogo as a starting point: http://processwire.com/talk/topic/59-module-want-form-builder/?p=11639 This takes care of formatting the form inputs to match the field type in the back end. I think this will do what you need if I have understood you correctly. There is a comment further down that page from myself that might also help.
  9. I am using that script of Ryan's on a site without any problems, but it is using an older version of PW, so perhaps it is a new bug.
  10. In the first code block you set $username, but then when you login, you use $input->post->user which according to the first line should at least be $input->post->username. Any reason you are not using $username here? Not sure what is wrong with the second block, but I'd be curious if that change to the first fixes it.
  11. If $user->user_city is return a number, then surely $user->user_city->title will give you New York etc and $user->user_city->name will give you new-york. You should use name for all cases where you are storing the city and checking it against another variable. Then use title to display it. However I think you know this already. Not sure if your user's city field is a single or multiple, but you should make it single, otherwise you might need to use $user->user_city->first()->title to get the title. I haven't used the FrontendUserProfiles module (I have done a custom setup), but I wouldn't worry about modifying it to suit your needs. Perhaps rename it so there is no chance of it being overwritten from the modules manager if you do an update. Or you could convert it so it is no longer a module - take the code and use it I don't think you need the linked page for the user's data - I still think the best way is to add those additional fields to the user template - that will make accessing this info much easier - eg: $user->user_city
  12. Hi Thomas and welcome to PW! You should be able to do this with a very basic custom module. I think this code from Pete should be a good start for you: http://processwire.com/talk/topic/1648-ok-to-change-page-name-path-after-save/?p=15232
  13. A few things: Is there some reason you can't simply use $user->user_city instead of the following. Remember that you can add custom fields to the user template. $options = $fields->user_city->getInputfield($user)->getOptions(); $u_city = $options[$user->user_city]; I always liked to use selected="selected" as this is XHTML compliant, but it seems that maybe just selected is now valid HTML5 The value of the option tag is whatever you set it to. If you set it to $city->name, then you want to use $city->name in the "selected" statement. Take a look at the source of the form on the rendered page to see what the value of the options is showing and echo the $session->current_city and see if they match. That should help you debug.
  14. Sorry, my fault: foreach($page->children('theatre_city='.$session->current_city) as $child){ or foreach($page->children("theatre_city={$session->current_city}") as $child){ On another note, you might want to modify this line in your select creation to the following: echo '<option value="'.$city->name.'"' . $session->current_city == $city->name ? ' selected="selected"' : '' .'>'.$city->title.'</option> This will ensure that the select dropdown highlights the current selected city.
  15. 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.
  16. 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.
  17. 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.
  18. 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.
  19. 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?
  20. 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!
  21. 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
  22. 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" ?
  23. 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();
  24. Quick glance - do you need to have: $first_page = $siblings->first()->id
  25. 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?
×
×
  • Create New...