Jump to content

hollyvalero

Members
  • Posts

    118
  • Joined

  • Last visited

Posts posted by hollyvalero

  1. 4 hours ago, kongondo said:

     

    * Yes! That's why I figured it wasn't available, but maybe could be...It's not a deal breaker because the pages would be filed under  City -> Location (like the dog park) and the breadcrumb nav is most likely to be to back up to the city level... but to "see all dog parks" I'd need to find a way to dynamically link that page URL data source.

    On the city  page I could...

    pages->find
    template=location (used by all)
    $page=city (locations are filed under cities)
    sort=title or sort by $ds->cat1 

     

    To link to a category since each is unique, maybe

    pages->find
    $ds->cat1=title
     

    but if it was a data source property

    echo $ds->cat1URL

    then you could avoid the find->step and it would be an elegant way to create a rich breadcrumb if using DS for page navigation elements.

    BTW -> I love this module. I had page reference fields originally and thought, good lord... what if there are 600 categories/subs/etc. It would be a nightmare to have to start at the top level each time. So this is really brilliant. 

     

     

     

     

     

  2. I'm working on a project to grow my programming skills a bit by making a Yelp-style directory that could be used for any dataset of things like parks in the state of Maine. I've created 3 templates so the page tree is the source of the categories for a drilldown like:  Outdoor Lifestyle (cat1) -> Parks (cat2) -> Dog Parks (cat3)

    Added dynamic selects and created a field called categorytree and set up the three so in the backend choosing top level, level 2 and level 3 categories is a dream. and having no problem displaying a basic breadcrumb... so when you get to the data dump for a location you get the breadcrumb: Outdoor life / Parks / Dog Park.

    $ds = $page->categorytree;
    echo "<ul class='uk-breadcrumb'>
         <li>$ds->cat1</li>
         <li>$ds->cat2</li>
         <li>$ds->cat3</li> 
    </ul>";

     

    Been going through the comments and I'm not sure this is possible, but wanted to make these live breadcrumbs...since all the data sources are pages... sort of like this, but obviously not this... Not sure in reading the previous entries whether this is possible? 

    <li><a href='$ds->cat1->url '>$ds->cat1</a></li>

     

     

    Screen Shot 2020-08-22 at 5.25.21 PM.png

    Screen Shot 2020-08-22 at 5.27.21 PM.png

    Screen Shot 2020-08-22 at 5.30.03 PM.png

  3. I've got the maps working on the front end and back end... got a single map with all points, and individual location maps on their pages. API set, account hooked up, everything seems to be awesome. 

    I just want to output the street address in addition to the map, so I popped in:

    <?php
    echo $page->marker->address;    // outputs the address you entered

    But when I do I am getting the full address PLUS lat./long and a little [n/a]->address - and want the FORMATTED ADDRESS:

    621 W Manchester Blvd, Inglewood, CA 90301 (33.961857, -118.367332, 12) [N/A]->addres

    ^ that's the formatted_address from Google maps... from the previous 25 pages of historic notes it seems that  there's no easy way to extract this. Any $page->map->address, lat, lon - all returns the same feed, no doubt due to Google changes.

    Options currently seem:

    - long reverse engineering of the address and JSON parsing, 
    - adding a second field and asking the data entry people to enter data twice...
    - using another script like Ryan's and coding via the API...

    Happy to have gotten this working  aside from this for the sake of getting it to work, and the map with all markers is lovely...but considering Google's charging for clicks? The Google Maps Text Formatter may be the easiest way to accomplish this for sites with light mapping needs. 
     

     

     

    screencapture-set4-hollycodes-net-conference-breakout-sessions-2020-05-19-14_30_51.png

  4. I have a pro fields repeater field that I am using for page top alerts on a home page (thank you, COVID-19) ... this dedicated set of repeaters could have more than one type. 

    --> repeater field is called cblock_alerts
    --> the first matrix type is alert 

    I have limited the entry to 2 in the back end (assuming one live and one in reserve) but I only want ONE to show up so you don't get stacked alerts.

    Normally I repeat everything in my repeaters so the code looks like:

    if ($page->cblock_alerts) {
        foreach ($page->cblock_alerts as $item) {
            if ($item->type == 'alert') {
                echo "

    I've tried several find, get, limit, and they all either don't work, show nothing, or show both repeaters. I don't really need the foreach here, but there could be another matrix item so the item type == alert is needed.

    I'm looking for something like this:

    if ($page->cblock_alerts) {
        foreach ($page->cblock_alerts as $item) {
            if ($item->type == 'alert') {
                $firstalert = $item->first();
                echo "

     

    or            

    $firstalert = $item('limit = 1');

    Lots of variations on these with no luck.  Tried random... grrrr.

     

     

  5. 2 minutes ago, Robin S said:

    If you are regularly building new sites you might want to consider creating a "default" profile that you install as the starting point of each new project. The idea is that you start with the core "blank" profile and...

    • install any modules that you tend to use in every site
    • configure everything the way that you want (module configs like the one mentioned above, /site/config.php settings, etc)
    • create any template files that are always needed (e.g. _init.php and _main.php depending on your output strategy)

    ...then export that profile with Site Profile Exporter. Now when you start a new project you install PW with this default profile and everything is set up how you like it to be.

    Different folks have different strategies but this one works well for me.

    That is - in fact - exactly what I do. I have a variety of pre-staged set ups for different purposes... I checked my set ups and they all had access for the trash to the editor... but this was a website I created about a year ago... it didn't include it, but now it does. ?

     

  6. On 6/20/2018 at 3:53 PM, ryan said:

    Nicely timed question— this is actually already in 3.0.107, and I've just been testing it locally this morning. If there are any pages in the trash that a user had edit permission to, then they can see the trash, and see those pages in the trash. The trash and restore actions also are now supported for non-superusers. They can't see pages in the trash that they don't have page-edit/page-delete permission, only superuser can see those.  

    I create a general "editor" role for managing web pages. And while I can go in as editor and choose the delete tab, once back at the page tree, I do not see the trashcan nor empty options. Once back in super-admin role I can see/trash.

    The editor role has all page delete permissions, and access to most everything but logs, advanced hanna code, db back ups, page locks and user administration. Any idea what I might need to do?

     

     

  7. 16 minutes ago, dragan said:

    @hollyvalero

    I tried it as well (hook is also in site/ready.php), and everything works just fine. Just copy-and-pasted the hook, and used the list example, and adjusted the selector. It even works within a partial I load via include_once() and cache the output with MarkupCache ?

    Do you run an ancient PHP version, by any chance? See Ryan's note about PHP < 5.3

    Also, did you find any hints with Tracy Debugger?

    Well, that explains it.  I had ready.php in the templates folder, not up a level in the /site/ folder.  I figured it had to be something stupid and I was right ?

    At least now I can get into hooks more... thank you!

     

     

  8. Making my semi-monthly attempt to get into hooks ?

    I tried adding Ryan's renderLinks to ready.php at one of my sites... and then tried various versions of the usage, like:

    echo $pages->find("parent=/")->renderLinks(); 

    in the templates.  I take it as a sign of progress that I am past the 500 server error, but the output I get is the single word "array"

    this is not urgent of course, but wondering if someone can point me in the right direction?

     

    10639939_ScreenShot2020-02-17at3_37_33PM.thumb.png.66256676078542c303e69d47854f24ec.png

     

     

  9. First of all, thank you so much for taking the time to slog through the set up - and all the screen snaps. 

    I switched the url redirect "/login/" to the page ID to see if that might help, but I think what I did wrong was that --> on the login page template, the editor role could view and EDIT<--. Not just view. All the rest looked the same as far as the set up.

    I agree that it's a better practice to create a new role instead of just using login-register.  Those changes seem to have fixed it... and the redirect($goto) is working too.  I assume maybe the login template can be only view access.

    Let me just add that bit of wisdom to my "when the bad thing happened" file. ?

    THANK YOU so much!! In the meantime I looked at Login Register Pro ... hopefully can offer either.

     

    h

     

     

  10. 1. using LoginRegister for a simple username/password to view a demo course.

    Vanilla installation:
     $modules->get('LoginRegister')->execute()  

    Login url is /login/ using login template that anyone can see -> and that's working.

    when not logged in, you see the form.  When logged in you see a logout link and copy that shows up upon logging in. -> that's working


    2. There is 1 template: demos (for the actual videos)  - viewable for login-register role, but not for guest.

    I have set the template to redirect to: /login/ if you are not logged in.
    when I go to the demo URL not logged in, I am bumped to /login/ -> that's working.
    http://test2.hollycodes.net/shop/view-demo-training-videos/security-awareness-for-it-professionals-demo/

     

    3.   the guest role can page-view all except demos  and login-register role can see all pages

     
    4. When logged in as super user, I see all pages correctly 

    5. HOWEVER

    If I go here: http://test2.hollycodes.net/shop/view-demo-training-videos/ 
    and follow the link to login: http://test2.hollycodes.net/login/
    and enter

    frank
    daypass123

    I get Welcome frank...and the welcome copy and a link to go to the courses...

    But when I click that course link to the demos template, it bounces me back to the login page, despite being logged in. 
    ----> What am I doing wrong? <------


    a. I was originally going to use login/register pro, but it seemed like overkill for a simple u/p combo...
    b. Then I tried to automatically bounce people back to the course list after logging in:

    <?php
    if($user->isLoggedin() && !$input->get('profile') && !$input->get('logout')) {
      $session->redirect('/shop/view-demo-training-videos/'); 
    } else {
      // let the LoginRegister module have control
      echo $modules->get('LoginRegister')->execute(); 
    }

    but the login just cycled between /shop/view-demo-training-videos/ and /login/ and melted down.  Which seems like  I should change it in the template, but that just makes no sense...

     

    ----> What am I doing wrong? <------

    I uninstalled login/register pro, there's nothing in the error logs...
    tried it in a fresh browser - same issues

    What dumb thing am I missing here?

    Screen Shot 2020-02-06 at 1.57.56 PM.png

  11. 5 minutes ago, Autofahrn said:

    I'd probably do the find and then check if $products contain the minimum amount. Otherwise you'll have two database queries.

    I had something like this but it wasn't working...


              $products = $pages->find("template=product, limit=9, sort=sort"  );   
               if($products > 3) {

              }
     

  12. I'm trying to come up with an automatic feature for a home page that will display 3 products (or more) in a slider carousel as long as there is a minimum of 3 items that qualify  If there are less than 3, they would just not show up.

     I've been trying to add a count and this is working but it seems, at best, inelegant...

     

         $total = $pages->count("template=product");
         if($total > 3) {
              $products = $pages->find("template=product, limit=9, sort=sort"  );
              }
     

     

    Is there a better/shorter way to put this?

     

     

     

  13. Hi!

    I'm working on formatting blog results. Currently I do a check for the first record and give it a bigger treatment, with a basic thumbnail/blurb/link for the rest...

     

    $items = $pages->find("template=articleblog|post, limit=30, sort=-cbdate");
    foreach ($items as $item) {
         if ($item == $items->first()) {
             [ this is where we do the larger photo, blurb, etc. since it's the newest]
       } else {
         [ standard thumb/blub/treatment]
      }

     

     

    I'd like to be able to extend this so that the newest record got the big treatment, and then, say the next 2-3 got something bigger than a blurb, followed by the older treatment.

    I've seen the counter for first/last

    $i = 0;
    $length = count($items);
    foreach ($items as $item) {
    if ($i == 0) {
    	// first
    } else if ($i == $length - 1) {
    	// last
    }
    $i++;
    }

    But my attempts to figure out how to do this and increment the counter are resulting in server errors... 

     

    $i = 0;
    $length = count($items);
    foreach ($items as $item) {
     if ($i == 0) {
        // first
     } else if ($i ==  1) {
        // second 
     } else if ($i ==  2) {
        // third 
     } else   {
        // all the rest
     }
    $i++;
    }

     

     

    Looking for a good tutorial or idea for figuring out how to increment the counter and compare the number to choose the formatting for those array items that are not first or last.

    thanks in advance!

     







     

  14. 2 minutes ago, Robin S said:

    Here is a more sophisticated version if you have a large number of siblings and don't want to include all of them in the pager navigation.

    
    <?php
    // Limit for number of sibling links
    $limit = 9;
    // Get the number of visible siblings
    $num_siblings = $page->parent->numChildren(true);
    // The default start value is zero
    $start = 0;
    // If the number of siblings is greater than the limit then we need to adjust the start value
    if($num_siblings > $limit) {
    	// Get the halfway point of the limit
    	$half_limit = floor($limit / 2);
    	// Get the index of the current page relative to its siblings
    	$index = $page->index();
    	// Adjust the start value to keep the current page within the sibling links
    	if($index > $half_limit) $start = $index - $half_limit;
    	if($num_siblings - $start < $limit) $start = $num_siblings - $limit;
    }
    $items = $page->siblings("start=$start, limit=$limit");
    // Next page and previous page relative to current page
    $next_page = $page->next();
    $prev_page = $page->prev();
    ?>
    	
    <?php if($items->count > 1): ?>
    	<ul>
    		<?php if($prev_page->id): ?>
    			<li><a href="<?= $prev_page->url ?>">Previous</a></li>
    		<?php endif; ?>
    		<?php if($start > 0): ?>
    			<li>&hellip;</li>
    		<?php endif; ?>
    		<?php foreach($items as $item): ?>
    			<li class="<?= $page === $item ? 'current' : '' ?>"><a href="<?= $item->url ?>"><?= $item->index() + 1 ?></a></li>
    		<?php endforeach; ?>
    		<?php if($num_siblings > $start + $limit): ?>
    			<li>&hellip;</li>
    		<?php endif; ?>
    		<?php if($next_page->id): ?>
    			<li><a href="<?= $next_page->url ?>">Next</a></li>
    		<?php endif; ?>
    	</ul>
    <?php endif; ?>

     2019-01-19_122136.png.d34405ea6b0b64cb1524ffa4f20afc58.png

    Oooh... Even better!  I will see if I can follow along!  Thank you!!

     

    h

  15. 1 hour ago, Robin S said:

    That's not how MarkupPagerNav works.

    *** Thank you.  The more I played with it the more I thought, "you know... this is for search results...I don't think this is the right application for the pager... so I 

    went on to do the next and previous page thing - less terrific than yours so I will be happy to try your code as mine is a little thin.

     

    But thank you for that. Suspicions confirmed. ?

     

     

     

     

     

    1 hour ago, Robin S said:

     

    
    <?php
    $items = $page->siblings();
    $next_page = $page->next();
    $prev_page = $page->prev();
    ?>
    
    <!-- Add whatever classes or extra markup you need to this unordered list -->
    <?php if($items->count > 1): ?>
    	<ul>
    		<?php if($prev_page->id): ?>
    			<li><a href="<?= $prev_page->url ?>">Previous</a></li>
    		<?php endif; ?>
    		<?php foreach($items as $key => $item): ?>
    			<li class="<?= $page === $item ? 'current' : '' ?>"><a href="<?= $item->url ?>"><?= $key + 1 ?></a></li>
    		<?php endforeach; ?>
    		<?php if($next_page->id): ?>
    			<li><a href="<?= $next_page->url ?>">Next</a></li>
    		<?php endif; ?>
    	</ul>
    <?php endif; ?>

     

     

    • Like 1
  16. Trying to create a report environment for a nonprofit with a lot of lengthy guides. 3 Templates: report cover, report TOC, report pages. 

    Cover will be simple http://test.hollycodes.com/a-short-history-of-flatbreads/
    TOC is a list in manual order of all pages http://test.hollycodes.com/a-short-history-of-flatbreads/table-of-contents/

    Report page is the actual report content.  These are the pages where I want pagination at the bottom in some format:  Previous   1   2  3  4   5   Next

    Page numbers are turned on for the Report page template (not TOC or Cover - do they need to be on for the parent pages?)

    I am trying this for pagination:

    - - - - - - - 

    $options = array(
      'numPageLinks' => 10,
      'listClass' => 'uk-pagination',
      'linkMarkup' => "<a href='{url}'>{out}</a>",
      'currentItemClass' => 'uk-active uk-text-bold',
      'separatorItemLabel' => '<span>…</span>',
      'separatorItemClass' => 'uk-disabled',
      'currentLinkMarkup' => '<span>{out}</span>',
      'nextItemLabel' => 'Next',
      'previousItemLabel' => 'Previous',
      'nextItemClass' => '',
      'previousItemClass' => '',
      'lastItemClass' => '',
    );
    
    $items = $page->parent->children("limit=2");
    $pager = $modules->get('MarkupPagerNav');
    echo $pager->render($items, $options);


     - - - - - - - 

    This is giving me the active page bold, the numbers, next & previous... but all the links are relative to the current page - whichever one you are on:

    http://test.hollycodes.com/a-short-history-of-flatbreads/table-of-contents/neanderthal-flatbreads/page2/
    http://test.hollycodes.com/a-short-history-of-flatbreads/table-of-contents/neanderthal-flatbreads/page3/

     

    Instead of going to the actual pages 

    http://test.hollycodes.com/a-short-history-of-flatbreads/table-of-contents/neanderthal-flatbreads/
    http://test.hollycodes.com/a-short-history-of-flatbreads/table-of-contents/indian-subcontinent/
    http://test.hollycodes.com/a-short-history-of-flatbreads/table-of-contents/what-makes-flatbread-flat/

     

    Been trying to suss out what I am doing wrong for a few hours and not seeing it... 

     

     

     

×
×
  • Create New...