Jump to content

LostKobrakai

PW-Moderators
  • Posts

    4,954
  • Joined

  • Last visited

  • Days Won

    100

Community Answers

  1. LostKobrakai's post in Syntax Highlighting Field Type HTML and/or PHP was marked as the answer   
    Like this?
    http://modules.processwire.com/modules/inputfield-ace-extended/
  2. LostKobrakai's post in output Textarea-Field without a-Tags was marked as the answer   
    If you won't need any markup you can use strip_tags(). Otherwise it will be a bit more complicated.
  3. LostKobrakai's post in How to use $page->isNew() was marked as the answer   
    isNew() will only be true, if a page was never saved to the db, which in terms of backend creation of pages is only till after the page add screen, where you put in the title/name of a page.
  4. LostKobrakai's post in Selector 'where all repeater items' was marked as the answer   
    $pages->find("!my_repeater.my_checkbox<1"); This should work. It means find all pages where NOT at least one repeater does have an unchecked checkbox.
  5. LostKobrakai's post in Render field based on their Dependencies was marked as the answer   
    For basic selectors this would have probably been enough. Though I'm not sure if it covers all edge-cases correctly.
    $isShown = $page->is($field->showIf);
  6. LostKobrakai's post in Cacheing output of XML API was marked as the answer   
    This would cache only the xml for an hour. 
    <?php $goodreads_api = 'xxxxxx'; foreach($page->children as $bundle) : foreach($bundle->goodreads as $goodreads) : $xml_string = $cache->get($goodreads->isbn, 3600, function() use($goodreads_api, $goodreads) { return file_get_contents('https://www.goodreads.com/search/index.xml?key='.$goodreads_api.'&q='.$goodreads->isbn); }); $book_xml = new SimpleXMLElement($xml_string); foreach ($book_xml->search->results->work as $book) : // content goes here endforeach; endforeach; endforeach;
  7. LostKobrakai's post in an unwanted button link shown on my custom Process module was marked as the answer   
    It's a class on the button. Just remove it to prevent the cloning.
  8. LostKobrakai's post in ProcessWire find help ("text=a, sort=price, text=b, sort=price") was marked as the answer   
    If the "texts" would be a options/page field then you can sort them in the page tree / field setup accordingly and willyc's last example would still work.
  9. LostKobrakai's post in $page->created in hookevent? very strange... was marked as the answer   
    You're probably triggering the hook on the newly created page object. The created timestamp is (probably) not part of that object by then and won't be available until the page is loaded from the db for the first time.
  10. LostKobrakai's post in Custom multidemensional PageArray (like a custom a PageTree) was marked as the answer   
    PageArray's (as well as it's parent class WireArray) can only hold one dimensional data on their own. You could however try using a WireArray to hold multiple PageArrays.
  11. LostKobrakai's post in Frontend editing question was marked as the answer   
    Depending on which method of adding the frontend editing you're using you migh need to specify the field and the pageid:
    https://processwire.com/blog/posts/front-end-editing-now-in-processwire-3.0-alpha-4/
  12. LostKobrakai's post in Does PW support organizing Template files in sub Dirs ? was marked as the answer   
    By default it's not possible to use subdirs, but you can use the settings for each template to change the file the template is associated with. Either just update it for some of your templates or just associate any template with some kind of routing.php, where you can implement any custom logic to route requests to the correct files.
  13. LostKobrakai's post in add image tags to upload was marked as the answer   
    foreach($product->image as $image) {
    $page->images->append($image->url);
    $page->images->last()->tags = "tag1 tag2";
    }

  14. LostKobrakai's post in Populating a page selector with a logged in user id using ready.php hook was marked as the answer   
    The function is a closure, which does have it's own variable scope, so local variables like $page or $user are not populated. You'd need to use one of those:
    wire('user') $this->user $event->user
  15. LostKobrakai's post in Using Repeater Items on Different Page was marked as the answer   
    There's a $ to much in $newspage->$news_items
  16. LostKobrakai's post in Pull content from Settings Page was marked as the answer   
    How about that? 
    $pages->get($mySettingsPageId)->body;
  17. LostKobrakai's post in Repeating and grouping fields for team page was marked as the answer   
    No need to duplicate any code here. The foreach is there to run multiple times on it's own.
    <div class="uk-grid uk-text-center team-thumbnails"> <?php foreach($page->Teammitglieder as $member): ?> <div class="uk-width-1-5 uk-container-center"> <img class="uk-thumbnail uk-border-circle" data-uk-modal="{target:'#<?php echo $member->id; ?>'}" src="<?php echo $config->urls->templates?>layout_images/g.wertich.jpg" width="130" height="130" alt="$image->description" alt=""> <div class="uk-thumbnail-caption"><?php echo $member->Team_Name; ?></div> <a class="more-infos" href="#<?php echo $member->id; ?>" data-uk-modal>Mehr Infos ...</a> </div> <?php endforeach; ?> </div> <!-- And later --> <?php foreach($page->Teammitglieder as $member): ?> <div id="<?php echo $member->id; ?>" class="uk-modal"> <div class="uk-modal-dialog"> <a class="uk-modal-close uk-close"></a> <div class="uk-modal-header"> <h2><?php echo $member->Team_Name; ?></h2> <img class="uk-thumbnail uk-border-circle team-detail" src="<?php echo $config->urls->templates?>layout_images/g.wertich.jpg" width="100" height="100" alt="$image->description" alt=""> </div> </div> </div> <?php endforeach; ?>
  18. LostKobrakai's post in Find Child's Parent's Children was marked as the answer   
    You can make it work with pagination, but it's a bit different to execute.
    // This part cannot use pagination, because we need all of john's comments, // but the whole selector construction is cacheable to minimize load // invalidate the cache whenever john does post a comment // optionally you can then also recreate the selector, so the waiting time // does hit John and not other users $johns = $pages->find("template=comment, comment_username=John"); $parents = $johns->explode(function($c){ return $c->parent->id; }); $parents = array_unique($parents); $commentsSelector = array(); foreach($parents as $parent){ $johnsFirstComment = $johns->find("parent=$parent, sort=created"); $commentsSelector[] = "afterjohn=(template=comment, parent=$parent, created>$johnsFirstComment->created, comment_username!=John)"; } $commentsSelector = implode(', ', $commentsSelector); // End cacheable $pages->find($commentsSelector . ', sort=created, limit=10');
  19. LostKobrakai's post in Remember log in + Redirect to requested URL was marked as the answer   
    Take a look at the information about session fingerprinting in wire/config.php. If you'd like to change the config for it please remember to copy it to the site/config.php first.
  20. LostKobrakai's post in Search by comma separated values was marked as the answer   
    May I ask why you're not using a PageField to reference users? *= does not support partial word matching and in this case there are no spaces, which is why it doesn't work. ~= would work, but only in db queries and not for runtime filtering.
  21. LostKobrakai's post in InputfieldPage in a search query was marked as the answer   
    ~= is only for textfield matching, a.k.a. matching inside of a single block of text. For multi-value fields just use = and it'll find you all pages holding that value in the field.
  22. LostKobrakai's post in Getting random pages very slow was marked as the answer   
    sort=random in the selector should work.
  23. LostKobrakai's post in Unimplemented operator was marked as the answer   
    Is h_age a textfield or a integer/float field? Only the latter ones should be able to use the >/< operators.
  24. LostKobrakai's post in The query string was marked as the answer   
    Take a look into MarkupPagerNav, which does exactly this for creating it's paginations.
    The issue you're facing is actually not an issue, but a common practice for frameworks of all sorts. The .htaccess file does rewrite the request to be able to enter the application always via the index.php. To still know where the user wanted to go the path must be passed as get variable. In case of ProcessWire this get variable is "it".
  25. LostKobrakai's post in selector grouped by parents was marked as the answer   
    $dishes = $pages->find("…, sort=parent, sort=XX");
    $parentID = null;
    foreach($dishes as $dish) {
    if($parentID === null || $dish->parent->id !== $parentID){
    $parentID = $dish->parent->id;
    // render restaurant headline
    }
    // render dish list item
    }

×
×
  • Create New...