Jump to content

DaveP

Members
  • Posts

    868
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by DaveP

  1. Since I released the source code, there's not been any feedback, so I assume my code is bad. For that reason, I'm going to commence with my above suggestion and split the module into two manageable pieces of code, starting with the comments module. This thread can now be deleted as I will no longer be releasing it as HermodBB.

    Hey, steady on, tiger, let's give it a try.

    I just installed the module on a fresh 2.7.2 install (Basic profile) and followed the instructions in the repo and everything installed beautifully. I also created rough root, forum and topic pages, just for testing.

    The first thing puzzling me is that I also added a new PW role 'member', expecting to give that role 'create topic' and suchlike privileges, but, to me, the config options in the backend aren't coming up where I'd expect them (at subforum level), but at topic level. And there's no sign of my 'member' role being offered the chance to do anything. Is there something I have done wrong?

    I would like to spend some time giving whatever help I can to help make this work.

    • Like 3
  2. If I understand the situation correctly, I would do it a bit differently. Have your Cards field just to specify the 'featured content' (3,5 & 7), and populate the others programatically.

    <?php
    $standardCards = $pages->find('selector');
    $featuredCards = $page->cards;
    
    $cardsNumber = 8;
    $featured = array(3, 5, 7);
    
    $currentStandard = "";
    $currentFeatured = "";
    
    $output = "";
    
    for($c = 1; $c <= $cardsNumber; $c++){
      if(in_array($c, $featured)){
        if(!$currentFeatured){
          $currentFeatured = $featuredCards->first();
        } else {
          $currentFeatured = $featuredCards->next($currentFeatured);
        }
        $output .= $currentFeatured; //or whatever to generate actual html
      } else {
        if(!$currentStandard){
          $currentStandard = $standardCards->first();
        } else {
          $currentStandard = $standardCards->next($currentStandard);
        }
        $output .= $currentStandard;
      }
    }
    echo $output;
    

    Hmm, is that a bit long-winded? I'm sure someone will come up with a far superior solution. :lol:

    Usual disclaimer - written in browser and completely untested.

  3. Little tip - because this modules page is just a page (everything's a page), it can have children.

    One thing that I don't think you can get back through it is a count of all the pages that would match a selector, to use for pagination, for example. But you can easily make a child page that returns $pages(selector)->count() and maybe other meta information (perhaps as a json object).

  4. Just read the blog post - wonderful!

    I have said it before and it stands repeating - one of the great things about PW (and there are many) is that updates and new features make so much sense.

    This field template/page template pairs is sooo powerful. Of course we could already do all this with includes and such, but one great strength of this being built in to PW is future maintainability. Someone (either someone else or me) looking at a template of mine in a couple of years would need to figure out how all these template partials are organised. Now, there's a standard way and it's documented here.

    • Like 3
  5. @Adrian Hmm, looks like a similar problem to sevarf2's. Late in the day here, so I'll revisit this over the weekend.

    @kongondo Would I be right in thinking that that method would entail an intermediate step, much like the one in the thread Adrian links to above? 

    @justb3a Tried a few variations with your suggestion, but no joy.

    If the worst comes to the worst, I could just call a new image every page load. I was trying to do some local caching and play nice with MapQuest's API.  :P

    <edit> Couldn't resist a bit more googling and http://stackoverflow.com/questions/10233577/create-image-from-url-any-file-type looks promising. No time to test now but I will report back at some point.</edit>

    • Like 1
  6. Nope, still not working, with your $page->images->add() style coding. This is the error

    Error: Exception: Unable to copy: http://www.mapquestapi.com/staticmap/v4/getplacemap?key=myAPIKey&location=PR7%202EJ&size=250,250&type=map&zoom=15&imagetype=gif&showicon=purple_1 => D:/wamp/www/ss/site/assets/files/1026/getplacemap_key_myAPIKey_location_L4_0TH_size_250-250_type_map_zoom_15_imagetype_gif_showicon_purple_1.com_staticmap_v4_getplacemap_key_myAPIKey_location_L4_0TH_size_250_250_type_map_zoom_15_imagetype_gif_showicon_purple_1 (in D:\wamp\www\ss\wire\core\Pagefile.php line 117)
    
    

    As far as I can tell I set up your module correctly - enabled just for map_thumbnail field and renaming to just mapthumbnail as it is a singular field and there will only ever be one image.

    PW 2.7.2 in case I forgot to mention.

    <edit>Take out both API key mentions.</edit>

  7. Adrian, I'm using a single image field so it's

    $p->of(false);
    $p->map_thumbnail = 'http://verylongurl.com?lotsofparameters=toolongfilename';
    $p->save();
    

    so it's slightly different. But the error is that PW can't move the file, so at least that suggests that it would work with a shorter file name. (Limit is ~260 characters.)

    Give me a moment to install the module again and I'll get back to you.

  8. Simple problem - I'm trying to save an image* from an external API and PW's API names in for its URL. The derived filename is too long for my filesystem. Is there any way (an appropriate hook would be lovely) to rename it before it is initially saved? (Kinda like 'Save As')

    *The image is a static map thumbnail from http://www.mapquestapi.com/staticmap/#getplacemap and, with a real API key inserted and the file path tacked on the front, the path+filename chokes my dev machine.

×
×
  • Create New...