Jump to content

Wanze

PW-Moderators
  • Posts

    1,116
  • Joined

  • Last visited

  • Days Won

    10

Community Answers

  1. Wanze's post in Sort problem: Selector with date needs empty dates last was marked as the answer   
    Hi Xonox,
    You could create a new PageArray and append the pages without the training start time at the end:
    $today = time(); $parent = $pages->get('/formacao/'); $trainings = $pages->find("parent=$parent, template=training, limit=6, !training_start<$today, sort=training_start"); $_trainings = new PageArray(); $empty = new PageArray(); foreach ($trainings as $training) { if ($training->training_start) { $_trainings->add($training); } else { $empty->add($training); } } $_trainings->import($empty); I'm sure there are more elegant solutions
  2. Wanze's post in Which fields have been changed and to what. was marked as the answer   
    Hi Sradesign,
    Finally could look at the implementation, turned out that you must enable tracking by values explicitly like this:
    $p = $pages->get('/'); $p->setTrackChanges(Wire::trackChangesOn | Wire::trackChangesValues); $p->title = 'new value'; var_dump($p->getChanges(true)); die(); Worked for me then, hope it helps!
    Cheers
  3. Wanze's post in Temporarily disable page was marked as the answer   
    You can still visit unpublished pages when logged in as superuser, that's why your template code gets executed.
    If you want to handle via this via unpublished status, simply add this on top of your template file:
    if ($page->isUnpublished()) { throw new Wire404Exception(); } ... or if you want a message remembering yourself that you need to unpublish the page, instead of a 404, echo out something and return
    Cheers
  4. Wanze's post in Multisite Error was marked as the answer   
    Your subdomains should point to the same document root where all the ProcessWire files are in (.htaccess, index.php, site, site-starter1 etc.), not to the site folders
  5. Wanze's post in $user in /site/config.php in older version PW 2.2.17 was marked as the answer   
    Hi Raymond,
    The problem is that the config file is parsed by ProcessWire before the API is ready, so the user object is not yet accessible.
    I suppose you could create an autoload module and set/overwrite config values there, based on the user.
    Cheers
  6. Wanze's post in Default Settings Toggle was marked as the answer   
    Hi rick,
    I don't think there is a setting, at least I've never heard of one... 
    Cheers
  7. Wanze's post in Selector to find pages with identical value in a field? was marked as the answer   
    Hi Webrocker,
    A direct MySQL query is the way to go here. The solution from LostKobrakai works, in the context of ProcessWire the query looks like this:
    SELECT pages_id, COUNT(data) AS count FROM field_legacy_id GROUP BY data HAVING count > 1 Now you can extract the page IDs from the result and delete these pages via the Pw API, as there is existing a duplicate post. Note that if the count is greater than 2 somewhere, you'd need to execute this query more than once.
  8. Wanze's post in Page count and position in list was marked as the answer   
    You're welcome. I often use the cheatsheet to lookup stuff: http://cheatsheet.processwire.com/
    Maybe the following works:
    $children = $page->parent->children(); $total = $children->count(); $pagePos = $children->getItemKey($page) + 1; // Assume the keys are zero based
  9. Wanze's post in Help importing comment dates was marked as the answer   
    Hi Orlando,
    If I remember correctly it's not possible to modify the created timestamp with the ProcessWire API. What works is to fire an SQL query for this job, something like this:
    UPDATE field_<comment_field_name> SET created=<timestamp> WHERE pages_id = <page_id> Edit: Welcome to ProcessWire 
  10. Wanze's post in For loop doesnt work properly was marked as the answer   
    Does your news template have a datetime field called "date" assigned? Maybe you named it differently?
  11. Wanze's post in Compare two pagefields was marked as the answer   
    PageArray::has() only accepts a single object. You need a loop, here's an example:
    $found = false; foreach ($user->locations as $location) { if ($page->locations->has($location) { $found = true; break; } }
  12. Wanze's post in Pagination bug - disappearing content was marked as the answer   
    Quote from the docs
     
    See: https://processwire.com/api/modules/markup-pager-nav/
  13. Wanze's post in simple template engine function was marked as the answer   
    Here you go: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/Functions.php#L855
  14. Wanze's post in ModuleJS and js autoload was marked as the answer   
    The ModuleJS::init() takes care of loading those scripts if they have the same name as your module, so you don't need to overwrite this method.
    Edit: If you need to append additional JS/CSS, call parent::init() first
  15. Wanze's post in Single Image Upload to $user template was marked as the answer   
    Hi mr-fan
    You need to add enctype="multipart/form-data" to your form tag Is "user_img" the name of your file input? If so, then I guess $input->post->user_img would return null, since this key is inside PHP's global $_FILES variable (not in $_POST) Edit: LostKobrakai wins Do you ever sleep?
    Cheers
  16. Wanze's post in Giving a non superuser permission to manage roles was marked as the answer   
    Hi quickjeff,
    You can create a permission "role-admin" and give your admin-role this permission. Any admin should then be able to manage roles.
    Note that I've not tested it myself, but found this comment: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Process/ProcessRole/ProcessRole.module#L26
  17. Wanze's post in 404 page not working was marked as the answer   
    You're welcome!
    I don't know what happened, this sounds strange.
    But you could try to create the table manually. Here's the SQL statement from the module code: https://github.com/apeisa/ProcessRedirects/blob/master/ProcessRedirects.module#L326 
    If you have phpMyAdmin installed or any other MySQL database administrator, execute it there.
    CREATE TABLE ProcessRedirects ( id int unsigned NOT NULL auto_increment, counter int unsigned DEFAULT 0, redirect_from varchar(255) NOT NULL DEFAULT '', redirect_to varchar(255) NOT NULL DEFAULT '', PRIMARY KEY(id), UNIQUE KEY(redirect_from) ) ENGINE = MYISAM;
  18. Wanze's post in ProcessDatabaseBackups results in 'Login failed' was marked as the answer   
    Check the entry $config->userAuthSalt in your site/config.php file. This hash must be identical with the one on your live site.
  19. Wanze's post in $image->description returns an empty string for guest users was marked as the answer   
    Hi hettiger,
    Welcome to ProcessWire!
    Do you have template cache enabled or using MarkupCache by any chance?
    If it's a multilang site: Does the guest user maybe have a language where the image description isn't filled/translated?
    Cheers
  20. Wanze's post in How to Iterate Through All Fields of a Repeater? was marked as the answer   
    Hi Stefan,
    The repeater field is PageArray holding pages. I'm not sure if a repeater can contain another repeater, if it's possible this wouldn't be a good idea in my opinion
    Extract your logic into a function that can be called recursive, this is just an example written in the browser, not tested:
    function setLanguageValue(Page $p, $language) { $pageFields = $p->fields; // iterate through all fields of the given page foreach ($pageFields as $field) { $type = $field->type; // only select a field if it is translatable if ($type == "FieldtypeTextLanguage" || $type == "FieldtypeTextareaLanguage") { $p->setLanguageValue($language, $field->name, "some dummy text"); } elseif ($type == "FieldtypeRepeater") { // Go recursive here $repeaterFieldName = $field->name; foreach ($p->$repeaterFieldName as $subpage) { setLanguageValue($subpage, $language); } } } $p->save(); } // Execute it $startPage = wire('pages')->get("/"); $russian = wire('languages')->get("ru"); setLanguageValue($startPage, $russian);
  21. Wanze's post in Changing style of Login Page was marked as the answer   
    Hi ivy,
    You have to change the Theme of the guest user to "Ergo". If a user is not logged in, ProcessWire knows him/her as "guest".
    Cheers
  22. Wanze's post in search by id was marked as the answer   
    Hi Blad,
    You can do this with some additional logic:
    if( $this->input->get->sSearch ) { $q = $this->sanitizer->text($this->input->get->sSearch); if (is_numeric($q)) { $selector .= "id=$q,"; } else { $selector .= "title|body%=$q,"; } }
  23. Wanze's post in Filtering Page Fields was marked as the answer   
    Specify the field you want to filter from the page as subfiled, e.g. hue.title~=$q
  24. Wanze's post in Can't get list working correctly was marked as the answer   
    You forgot to foreach loop over the gigs of today. $heute is a PageArray, not a Page.
    Cheers
    Edit: Marcus won the race
  25. Wanze's post in Setting the user language via api was marked as the answer   
    I was having a similair issue, see here: https://github.com/ryancramerdesign/ProcessWire/issues/409
    But ryan fixed it and the solution worked for me.
×
×
  • Create New...