Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Community Answers

  1. kixe's post in Custom Sort Child Pages was marked as the answer   
    Time ago I needed something similar. I solved it with a small script. You may use it as a starting point:
    $media = wire('pages')->find('parent=1034,template=medium,include=all'); $media->sort('media_type,status,title'); foreach ($media->getValues() as $key => $medium) {     $medium->of(false);     $medium->sort = $key;     $medium->save();     // var_dump($key.' - '.$medium->sort.' - '.$medium->media_type.' - '.$medium->title); }
  2. kixe's post in Method WireArray::each() doesn't work as expected was marked as the answer   
    After digging a while I found out it has to do with namespace.

    "is_callable() doesn't seem able to resolve namespaces. If you're passing a string, then the string has to include the function's full namespace."
    found here: php.net/manual/en/function.is-callable.php#107105
    $featured->each('\ProcessWire\preparePost'); // works $featured->each(__NAMESPACE__.'\preparePost'); // works $featured->each('preparePost'); // works ONLY if no namespace is declared I posted an issue on github:
  3. kixe's post in Download uploaded image was marked as the answer   
    /**  * Send the contents of the given filename via http  *  * This function utilizes the $content->fileContentTypes to match file extension  * to content type headers and force-download state.  *  * This function throws a WireException if the file can't be sent for some reason.  *  * @param string $filename Filename to send  * @param array $options Options that you may pass in, see $_options in function for details.  * @param array $headers Headers that are sent, see $_headers in function for details.  *    To remove a header completely, make its value NULL and it won't be sent.  * @throws WireException  *  */ function wireSendFile($filename, array $options = array(), array $headers = array()) {     $http = new WireHttp();     $http->sendFile($filename, $options, $headers); } Usage
    $file = $page->filefield->first()->filename(); // or $page->filefield->filename(); depending on your settings wireSendFile($file, array('forceDownload' => true, 'exit' => true)); Example
    Allow url segments in the template where your button and image exists. $img = $input->urlSegment1? (int) $input->urlSegment1:0; $download = $input->urlSegment2 == 'download'?true:false; $file = $page->filefield->eq($img); if ($download) {     wireSendFile($file->filename(), array('forceDownload' => true, 'exit' => true)); } else {     echo "<img alt='' src='{$file->url}'/>";     echo "<button><a href='$number/download/'>Download Picture</a></button>"; }
  4. kixe's post in How to renew access to ListerPro and ProFields forums? was marked as the answer   
    You can do this from your forum account -> Client Area
  5. kixe's post in Where can I find the translation strings for wiredate was marked as the answer   
  6. kixe's post in Name Format Children was marked as the answer   
    Find attached the first Alpha Version of the Module ProcessSetupPageName with Multilanguage Support. I tested it under various circumstances and it is doing fine with one exception: Until now it doesn't work together with 'Page Name Extended' (since PW 3.0.12) which allows UTF8 Page Names. Module requires PHP >= 5.4.x
    Download from here:
    EDIT: Removed link, download last version from here: https://github.com/kixe/ProcessSetupPageName/archive/master.zip

    Would be nice if you could test it and give a feedback to me. Thanks in advance.
  7. kixe's post in How to redirect back to home of current language after login was marked as the answer   
    This is only true if language of current user (set in backend) is default.
    // define language var before login take current language of page $language = $user->language // redirect to this language after login $session->redirect($pages->get("template=home")->localUrl($language)); Small hints
    1) Read the docs https://processwire.com/api/multi-language-support/multi-language-urls/
    2) use http://example.org/jpn/login instead of http://mydomain.com/jpn/login
  8. kixe's post in I want to have a front-end dashboard for each registered user was marked as the answer   
    Assuming that each user should have access only to his own account/ content, there is no need to work with UrlSegments since you have access to the $user API. The output of example.org/dashboard/ can be individually to each user.
    Create a role 'frontenduserrole' without any permission. Create a template  dashboard and a file dashboard.php like if ($user->isLoggedin() && $user->hasRole('frontenduserrole')) { echo "Welcome back $user->name"; } else echo "You need to login first.";
  9. kixe's post in Searching select option field type possible? was marked as the answer   
    Correct Syntax for Fieldtype Select Options
    $optionsfield // return id (string) $optionsfield->id; // return id (int) $optionsfield->title; // return string USE THIS or $optionsfield->value; // return empty string or value (if your option settings like '1=value|title') // dot syntax in selector string $pages->find('optionsfield.id=2'); Docs:

    $page->manufacturer return id as a string, NOT the title!
  10. kixe's post in Export fields/templates/configuration from one site to another was marked as the answer   
    Here comes a small Christmas Present
    Go to setup > templates or setup > fields and find 2 important (or exportant) buttons below the list in the right corner to go here:

  11. kixe's post in temporarily deactivate (default) language was marked as the answer   
    // set new default language
    $default = $languages->get('german');
    // redirect
    if (!$user->isLoggedin() && $page->localUrl($default) != $page->url) $session->redirect($page->localUrl($default));
  12. kixe's post in Select Options classes based on selections was marked as the answer   
    echo use __toString() function and will return a string like '1'. In your case use API like:
    $image->issue_raw_image_width // returns (string) '1' $image->issue_raw_image_width->id; // returns (int) 1 $image->issue_raw_image_width->title; // returns 'Full' $image->issue_raw_image_width->value; // returns '' // settings: 1=Full|myvalue $image->issue_raw_image_width->value; // returns 'myvalue' Have a deeper look here: https://processwire.com/api/modules/select-options-fieldtype/#separate-option-values
  13. kixe's post in Save and display custom userfields was marked as the answer   
    Welcome to the forum. You should read some tutorials, like this one.

    In ProcessWire nearly everything is a $page (even users, roles, permissions)
    If you want to assign more fields to the user template.
    Create the fields, you need Go to templates. Select Filters, Show system templates Select template 'user' and add any field you have in your system If you want to see the fields in the user profile, you have to add them in the settings of Module ProcessProfile.

  14. kixe's post in how to sort children of children was marked as the answer   
    The secret is to create a nice selector and use the API correctly. $pages->get() returns a single page, whereas $pages->find() returns a page array.
    /** * has_parent=1016 selects all children and grandchildren of the page with id = 1016 * parent!=1016 excludes the children (first generation) **/ $articles = $pages->find("has_parent=1016,parent!=1016,sort=title");
  15. kixe's post in No rich editor in my text area field? was marked as the answer   
    Under 'Details' Tab in your field settings you could define the Inputfield Type. Select 'CKEditor'. Done
  16. kixe's post in [Solved] Unable to save data in custom field on user profiles was marked as the answer   
    Since a while I notice a problem close to yours. It happens just in case of superuser. Adding some custom fields to the user template results in inability to change the values via Admin->Access->Users as loggedin Superuser (id=41). It works with ProcessProfile. After changing values of a specific field one time in Profile it becomes possible via Admin->Access->Users too. Editing other profiles works all the time. Couldn't find the cause.

    Edit: 5.07.15
    Allowance to edit user fields of the current user is based on the cofiguration in Module settings of ProcessProfile. If you have unchecked a field, you can't edit this field. This is default for custom fields. Change the settings in the module to give edit permission for these fields.
  17. kixe's post in Fatal Error Page created via API if Template has Filefield was marked as the answer   
    I made many changes to the module. savePage method is different in my module. It is working proper with last PW Versions, even with new fields like ProfieldsTable or so.
    I don't want to render an image or file before page is saved. I know that an id is needed to create the assets-folder. Filefield is not rendered before page is saved. I excluded the field by skipping it in the render method. But no success. If it is part of the template the error occurs anyway.
    Found a solution by adding a hook to the render method in the module in case of new page.
             // prevent error if fieldtype file or image is assigned and page has id = 0         $this->addHookBefore('PagefilesManager::path', function ($e) {$e->replace = true;$e->return = null;});
  18. kixe's post in Language Support: auto create blank translation files was marked as the answer   
    This Topic should be marked as answered.
    Video Tutorial

    By the way before this option was implemented in core you could enable it by installing my LanguageTranslatorPlus Module which exists since 10/2013.
  19. kixe's post in BUG: FieldtypePageTitleLanguage was marked as the answer   
    follow the topic here:
    discussion closed
  • Create New...