Jump to content

Tyssen

Members
  • Posts

    354
  • Joined

  • Last visited

Posts posted by Tyssen

  1. I'm going to be building a real estate website soon and am exploring my options. The site will have some pages that will be native to PW, but all their property listing information will come from an XML feed from an external provider.

    What's the best way to approach this? I've come across http://modules.processwire.com/modules/rss-feed-loader/ but is it possible to do searching, categorisation and pagination using that?

    Or is there a better way to approach it?

  2. Since upgrading from 3.0.32 to 3.0.41 and higher, the save buttons on entries don't work correctly on the production server (fine on the local development server running MAMP); the extra options are missing from the header button and clicking on the extra options from the button in the footer just returns you to the top of the page. Hitting just Save on either header or footer button saves the entry OK, so currently there's no ability to save & exit, save & view etc.

    Both local and production servers are running PHP 5.6. What other differences between servers might be causing this problem?

  3. Is it possible to have different breakpoints for different image sets? Or some way to control the value for the sizes attribute?

    For instance, for hero images that are going to be full width of the page I'll want different sizes than if I'm displaying a small author headshot which just needs a 2x or 3x version for HiDPI devices.

  4. The bits I left out are:

    <img src="'.$book->best_book->image_url.'" alt="">
    <h3 itemprop="name"><a href="https://www.goodreads.com/book/isbn/'.$goodreads->isbn.'">' . $book->best_book->title .'</a></h3>
    <p class="bundle-book-author">by '. $book->best_book->author->name . '</p>
    

    where it says // content goes here

    If this is really the case, you should either generate unique name for each cached portion of the content OR cache them together instead of book-by-book.

    I really just want to cache the XML output itself so that I can continue to work on the template markup and styles without having to wait several seconds for each page refresh. When you say generate a unique name for each cached portion, do you mean with a count and then something like ${'var' . $i}?

  5. I'm working on a site that is using the Goodreads API but I'm finding the page very slow to render so would like to speed it up by cacheing the output of the API.

    The page is made up of several child page 'bundles' each of which displays a selection of books which are chosen with a repeating field containing ISBN numbers.

    $goodreads_api = 'xxxxxx';
    
    foreach($page->children as $bundle) :
    
      foreach($bundle->goodreads as $goodreads) :
    
        $xml_string = 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;
    

    I've looked at the Markup Cache module but when I try cacheing the second foreach loop, I get the correct number of bundles and the correct number of books, but same output for every book.

    If I cache the first foreach, I get the correct number of bundles, but only one book and again, the same content for each bundle.

    So is Markup Cache the way to go, and if so, what am I doing wrong, or if not, what else should I be looking at?

  6. I'm working on a sporting website which has a template for outputting fixtures and scores. I've enabled frontend editing for the relevant field on the page by adding an edit attribute to HTML tags and it works fine when editing the individual entry.

    But I also have another page using a different template which compiles all the weekend's fixtures onto a single page for easy viewing.

    I'd like to be able to edit all the results from this single page rather than having to visit each page individually but when I do, I get:

    ProcessPageEdit - Field 'xxxxx' is not applicable to this page

    Is there a way around this?

  7. I'm just trying this out for the first time and wondering how to do the following things in Twig.

    $modules->isInstalled("AdminLinksInFrontend") ? $modules->get("AdminLinksInFrontend")->render() : "";
    <?php echo AIOM::CSS('../../assets/css/style.css'); ?>

    Also, when trying to do

    <script>{% include "../../assets/js/fonts.min.js" %}</script>

    I get

    Error: Exception: Looks like you try to load a template outside configured directories (../../assets/js/fonts.min.js) in "_layout.php" at line 23. (in /site/modules/processwire-template-twig-replace/Twig-1.18.0/Twig/Loader/Filesystem.php line 235)

    Is there a place to configure directories? Or another way to allow directory traversal?

  8. I'm using this:

    $categories = $pages->get(1077)->children->shuffle();
    
    foreach($categories->slice(0, 6) as $category) :
    
      include("./inc/category-items.inc");
    
    endforeach;
    

    to randomise and display only 6 items of a certain page's children.

    Now I also need to exclude children which have a certain template from the output. I did have:

    if($category->template->name!='exclude') include("./inc/category-items.inc");
    

    but that sometimes results in only 5 items being shown.

    What do I need to do to the $categories array before it gets sliced?

  9. I've implemented a site search on a site and am a bit confused about how it processes results.

    For instance, a search for art union produces no results, same for a search for art, but a search for union produces 5 results including the one I was hoping would come up which has a title of art union.

    How/why is that happening and is there anything to configure to improve the results?

    My search form looks like:

    <form action="<?php echo $pages->get("template=search")->url; ?>" method="get">
    <input type="text" name="q">
    <button type="submit">Search</button>
    </form>
    

    and the search template:

    if($q = $sanitizer->selectorValue($input->get->q)) :
    
      $input->whitelist('q', $q);
    
      $matches = $pages->find("title|body|summary~=$q,template!=admin, limit=50");
    
      $count = count($matches);
    
      if($count) :
        foreach($matches as $m) :
          …
        endforeach;
      endif;
    else:
      …
    endif;
    
  10. I'm using a repeater field for holding stock levels of different items and when all the rows' quantity columns equal 0, I want to set another stock checkbox field to off.

    I'm doing this in the template that displays the product:

    foreach($page->inventory as $stock) :
    
      $stock_total += $stock->qty;
    
      if($stock_total==0) :
        $page->of(false);
        $page->stock = false;
        $page->save();
      endif;
    
    endforeach;
    

    but it's setting $page->stock to off whenever the page is refreshed regardless of whether $stock_total = 0 or not. Why is that?

  11. I have a series of products which are attached to 'collections' which are their parent pages. I need to be able to output the products by their parents order. At the moment I have this: 

    $products = $pages->find("template=product,stock=1");
    

    which worked fine when I first created the site because all the products were entered in the correct order, but now a new collection has been added that needs to go first. (Parent pages have a different template than the individual products.)

    I've tried adding sort=sort but as mentioned in the docs it doesn't really produce the desired result.

    So how would I go about it?

×
×
  • Create New...