Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Community Answers

  1. adrian's post in Add some pages into PageArray (problems) was marked as the answer   
    What you want is this:
    $matches = $pages->find($selector); $the_page_array = new PageArray(); foreach($matches as $match) { if ($match==condition_blah_blah) { $the_page_array->add($match); }
  2. adrian's post in wire('pages')->get with a var in get was marked as the answer   
    I don't see where you are defining the $target in:
    $targetPage = "color_items_".$target; Also, keep in mind that "/color_items_desktop/" is not exactly the same as "color_items_desktop" which is what I am expecting you are ending up with.
  3. adrian's post in Move fields from "Settings" tab to "Content" tab in the Page Editor? was marked as the answer   
    Check out advanced mode in config.php and you'll have this for each template:

    Maybe doesn't take care of everything you need, but remember that the status can also be changed from the Page List view via the extended (after the arrow) action buttons.
  4. adrian's post in Per branch permission was marked as the answer   
  5. adrian's post in Dev on Live Server - Hook to Change Template was marked as the answer   
    Tracy to the rescue: https://processwire.com/blog/posts/introducing-tracy-debugger/#template-path-panel

    or you could place something like this in your site/ready.php file:
    if($user ......) { $page->template->filename = '_dev-' . $page->template->filename; } else { }  
  6. adrian's post in Hook to change uploaded image(s) filename was marked as the answer   
    You could use this module: http://modules.processwire.com/modules/process-custom-upload-names/
    Or if it looks too heavy for your needs, grab some code from it:
    InputfieldFile::fileAdded - https://github.com/adrianbj/CustomUploadNames/blob/master/ProcessCustomUploadNames.module#L97
    Frontend API calls
    Pagefile::install -  https://github.com/adrianbj/CustomUploadNames/blob/master/ProcessCustomUploadNames.module#L101
  7. adrian's post in Nothing can be saved in the admin was marked as the answer   
    Maybe it's a cache issue since you can't get to the admin to do a Modules > Refresh, try emptying the "caches" database table. Sorry you said you already did that
    I think there is something though in the fact that all your other pages work, just not the homepage and the admin.
    If you still have no luck, if you PM me access details (FTP and PW login) I'd be happy to take a look for you.
    Unrelated, but you have a JS syntax error - take a look at the console.
    PS It seems unlikely, but have there been any changes made to the .htaccess file recently. Did you replace it when you upgraded to 2.7.2?
  8. adrian's post in unread status was marked as the answer   
    Create a page field on the page's template that links (Parent of Selectable Pages) to the "users" parent page. That way you can populate this list with all the users that have read the page using the API when the page is viewed.
    $page->of(false); $page->viewed->add($user); $page->save('viewed'); $page->of(true); Then you can make use of that field to check to see if the current user is listed in the "viewed" field.
  9. adrian's post in Single Image, like logo as global File Type was marked as the answer   
    Hi @nirgendswo and welcome to the forums.
    You can store the image on the homepage (or a dedicated settings page) and define a variable that grabs the path to the logo:
    $logoUrl = $pages->get('/')->logo->url(); You can do this in a file that is included for all templates - perhaps and init.php - it really depends on how you are structuring your template files and how you are outputting.
    PS - you may also find this discussion useful: https://processwire.com/talk/topic/12198-modifying-config-property-eg-sitesettings-from-readyphp/
  10. adrian's post in Cannot edit or delete images in image field after update to 3.0.18 was marked as the answer   
    In addition to the core cropping functionality, there are two third party cropping modules:
    Neither of these work properly in PW3. The one you are using is tagged as compatible up to PW 2.4 only. The other one has a dev branch (https://github.com/horst-n/CroppableImage/tree/PW3) that works for 3.0.17 only. 
    You should have a read of these threads:
    Not everything is relevant, but there is a lot of discussion about further enhancements to cropping in the core to allow for predefined crop ratios etc. I think if you are wanting PW3, then unfortunately you will need to be satisfied with the core cropping for the time being.
  11. adrian's post in Returning list of pages belong to a list of users was marked as the answer   
    Try: created_users_id= as the selector, rather than user.
  12. adrian's post in Preventing Hook Loop was marked as the answer   
    Typically the easiest way to avoid loops with save hooks is to just save the field, rather than the whole page. So, do:
    $pageToSave->save('relatedPageField'); // or whatever the name of the field is
  13. adrian's post in Users display page rewrite url? was marked as the answer   
    Unless I am missing something obvious, it should just be a matter of enabling url segments on your home template, then using the value of the segment to get the page details for that user name.
  14. adrian's post in Having trouble saving data from a post form? was marked as the answer   
    Ok, so just save the field on the current page:
    $page->of(false); //sorry, I forgot this in the above examples $page->lp_item = $sanitizer->text($input->post->lp_item); $page->save('lp_item'); You can make it even shorter with:
    $page->setAndSave('lp_item', $sanitizer->text($input->post->lp_item)); That's it!
    Don't forget though if you have multiple users editing the same field on the same page you may want to deal with possible conflicts if they are editing at the same time.
  15. adrian's post in FieldTypePage was marked as the answer   
    You need to reference the field from the selected page(s).
    If the page field is set to store multiple pages you usually want to foreach through them:
    foreach($page->page_field as $pf) {     echo $pf->title; } That will return the titles of all the pages selected.
  16. adrian's post in FieldtypeCropimage croppableimage issues on PW3.x was marked as the answer   
    Are you using the correct branch of Croppable image? A new PW 3.x version was just posted by horst: https://processwire.com/talk/topic/8709-croppableimage/?p=119694
    Downgrading from 3.x to 2.x has been easy for me - use the Upgrades module, or manually copy over /wire/, index.php, and .htaccess files from PW 2.x and it should be fine.
  17. adrian's post in User image upload was marked as the answer   
    I think there is still an outstanding bug (https://github.com/ryancramerdesign/ProcessWire/issues/1803) with images on user pages - it seems like outputformatting is always off which results in the need for first(), even when maxFiles is set to 1.
    Try this: $user_image->first()->url
  18. adrian's post in Children of a page as a role even when not logged in was marked as the answer   
    Try check_access=0 in your selector:
    foreach ($top->children("check_access=0") as $child)
  19. adrian's post in Pagination - Limit an existing array was marked as the answer   
    Hi, and welcome to the forums!
    When paginating, you need to put the date check in the initial pages selector. You should do that anyway because it is much more efficient to only get the pages you need in the first place, rather than getting them all and limiting later on.
    $allNews = $page->children("template=news, date<=".strtotime('now')); Keep in mind that I think you also have another issue - using strtotime('now') or time() will always get all articles. You want to be comparing date to date, not date to a timestamp.
  20. adrian's post in Using Switch Statement with Select Options Fieldtype was marked as the answer   
    Maybe you have simplified your example, but why not simply do this:
    echo "<div class='container inner-{$page->switchColor}'>"; or to take care of no selection:
    $switchColor = $page->switchColor ? $page->switchColor : 'green'; echo "<div class='container inner-{$switchColor}'>"; PS I think you might actually be looking for $page->switchColor->value or $page->switchColor->title but I would need to confirm as I haven't used the Options fieldtype very often.  Look at the docs: https://processwire.com/api/modules/select-options-fieldtype/#separate-option-values
  21. adrian's post in Ability to sort and search through users in admin was marked as the answer   
    I know this thread is old, but happened to notice someone browsing it today so I thought I should "close" this now that the Users page in the admin uses the Lister interface which makes it very easy to search and sort users.
  22. adrian's post in Error when uploading image: Field 'caption' doesn't have a default value was marked as the answer   
    Yup, just delete that field from the DB and it should be fine again.
  23. adrian's post in WireMail configuration for recover password on localhost was marked as the answer   
    There is a setting for the Forgot Password module that lets you set the from email address.
  24. adrian's post in Saving to file programatically - a puzzle was marked as the answer   
    You don't appear to be saving the page anywhere, so do this:
    $p->save('textJSon'); after you set the $value
  25. adrian's post in Processwire 3 - using the API in Open Cart - wee hitch was marked as the answer   
    Looks like the homeboximage field is not set to "1" for the Max Files Allowed setting. Either change that, or do:
    echo $homebox->homeboximage->first()->url;
  • Create New...