Jump to content

hollyvalero

Members
  • Posts

    118
  • Joined

  • Last visited

Posts posted by hollyvalero

  1. This is my dumb question for the week. ?  I like to clean up unneeded server files... and over time I see a few duplicates with a "." in front of the name... with duplicates below that don't have the leading dot - I assume the .dotVersion is a saved version after a more major upgrade. Should I delete the .TextformatterVideoEmbed ? Any reason to keep it?

     

    Screen Shot 2021-08-23 at 10.32.27 AM.png

  2. While I was looking for a workaround to my MarkupSimpleNav borking over multiple items separated by a pipe:
    'selector' => 'template!=home|blog|category'

    I did an update of a production site and found a similar problem with:
    $features = $pages->find('template=post|articleblog, limit=1, sort=-date');

    Which makes me wonder if this is a pagefinder.php selectors problem and not markupsimple nav? Everything in this installation was 100% up to date EXCEPT the (Dev) upgrade and when I updated that, this OR-condition not supported showed up.

    933796088_ScreenShot2021-08-21at1_35_19PM.thumb.png.3e1bd65d71eaee9f4e0837722a428ab6.png
    779966545_ScreenShot2021-08-21at1_38_18PM.thumb.png.547aa7657165f0846482a85c990fda22.png

  3. Hi, this used to work when using MarkupSimple Navigation - trying to omit certain pages so "Blog" would appear in the top menu, but there wouldn't be a dropdown menu with endless posts...


    $treeMenu = $modules->get("MarkupSimpleNavigation");
    $rootPage = $pages->get("/");
    $options = array(
    'current_class' => 'current-menu-item',
    'has_children_class' => 'parent',
    'max_levels' => 2,
    'outer_tpl' => '<ul id="main-menu">||</ul>',
    'inner_tpl' => '<ul class="sub-menu">||</ul>',
    'item_current_tpl' => '<strong>{title}</strong>',
    'selector' => 'template!=post|glossary|category'
    );
    echo $treeMenu->render($options, $rootPage); // render menu

     

    EDIT:  Played around a bit with this, and it does work with one template as the divider | is what is causing the problem, so this works and if you have only one template that needs this, you're set. 
    'selector' => 'template!=bloghome'

     

    Second edit: I think this was triggered by DEV update 3.0.183 - so this should fix itself, but leaving this here in case anyone has a similar problem.... 

     

  4. 56 minutes ago, LMD said:

    I do not understand what you were trying in your examples -- I think maybe you are muddled about how $sanitizer works?  All it does it return the sanitized value.

    ** Ah, thank you! I was thinking I had to santize the whole batch separately and then try to match the active post...  I only need to sanitize the active post because that's the part that is in the find->page thing... got it. 

     

     

     

  5. What I am trying to do: On a blog post page, I am adding a small snippet at the bottom that has the 2 most recent blog posts by the current page author, excluding the blog post title that we are actively reading. That part works...

    // if this page has an author listed, s/he becomes the active $author and this page is the $activepost
    if ($page->cbpage2->id) {
         $author = $page->cbpage2;
         $activepost = $page->title;

    // Get the posts...
     $articles = $pages->find("template=post, cbpage2=$author, limit=2, title!=$activepost, sort=-cbdate" );

    // and then format the results for each found...
        foreach ($articles as $article) {
              echo "...";
              }

     

    One author post had a comma in the blog post title which broke this, and I assume this needs to be santized because I reference title!=$activepost
    this didn't work...

         $articles = $pages->find("template=post, cbpage2=$author, limit=4, title!=$activepost, sort=-cbdate" . $sanitizer->selectorValue($title));
     

    I assume I have to sanitize BEFORE: $pages->find  since it's dragging in the comma, but since I have the $activepost = $page->title; No method I've tried seems to be working. Rather than tell everyone "don't use commas!" I'd love to figure this out, but coming up with tragic results like: 

         $dirtyarticles = $pages->find("template=post, cbpage2=$author, limit=4, title!=$activepost, sort=-cbdate")
         $cleanarticles = $sanitizer->selectorValue($dirtyarticles));

    and that sure isn't right... 

     ?

  6. On 11/30/2013 at 5:54 AM, ryan said:

     

    function truncateText($text, $maxlength = 200) {
      // truncate to max length
      $text = substr(strip_tags($text), 0, $maxlength);
      // check if we've truncated to a spot that needs further truncation
      if(strlen(rtrim($text, ' .!?,;')) == $maxlength) {
        // truncate to last word 
        $text = substr($text, 0, strrpos($text, ' ')); 
      }
      return trim($text); 
    }
    
    $summary = truncateText($page->body); 
    echo "
      <a href='$page->url'>$page->title</a>
      <p class='summary'>$summary</p>
      ";
    

    I've been using this approach for just what you mentioned... shortening blurbs and tucking them into a page with several other items of like type... but this works great but launders out numbers... 

    So something like "Average temperature data for each month from 1880 to 1990 to is displayed"...

    Comes out as "Average temperature data for each month from to to is displayed"...

    I see a code mention of mixed, for a mixed string, but can't figure out how to incorporate it...

     

     

  7. EDITING TO ADD FIX:  after comparing the two installations, one had Hannacodehelper still installed - so I deleted that and it's working just fine now.

     

    I have a website with a lot of charts in Hanna Code snippets. When trying to edit pages, getting a big fatal error - which is new. When I installed this it was working fine, so something since then seems to have triggered it.

    Fatal Error: Undefined class constant 'DEFAULT_OPEN_TAG' (line 111 of site/modules/HannaCodeHelper/HannaCodeHelper.module)

    - everything is up to date
    - PHP version is 7.3
    - compiled files cleared
    - cache cleared

    Error log in PW says:
    Fatal Error: Undefined class constant 'DEFAULT_OPEN_TAG'
    Line 111 of /site/assets/cache/FileCompiler/site/modules/HannaCodeHelper/HannaCodeHelper.module

    Referring to: 

    // basic settings
            $data = $this->modules->getModuleConfigData('TextformatterHannaCode'); 
            $openTag = isset($data['openTag']) ? $data['openTag'] : \ProcessWire\TextformatterHannaCode::DEFAULT_OPEN_TAG;
            $closeTag = isset($data['closeTag']) ? $data['closeTag'] : \ProcessWire\TextformatterHannaCode::DEFAULT_CLOSE_TAG; 

    Front end is working fine, and overall backend is accessible.

    Any clues?

     

     

  8.  In a blog, I have a page field that references a library of writers (cbpage2) so their info doesn't have to be reentered for each post.
    At the bottom of the post I wanted to list, " the last 2 posts by THIS AUTHOR, but obviously not include the CURRENT PAGE POST"

    EDITING TO REMOVE ALL BUT THE apparent answer

     When I used title to match the variable $activepost it seemed to break - title too long? But when I matched it to the ID it seemed to work... 

        $author = $page
            ->cbpage2->id;
        $activepost = $page->id;

        $articles = $pages->find("template=post, limit=50, cbpage2=$author, id!=$activepost, sort=-cbdate");

     Screen Shot 2021-04-15 at 2.56.35 PM.png

    Screen Shot 2021-04-15 at 3.11.42 PM.png

    • Like 1
  9. Pagination usually works just fine. I had 2 identical production sites - I was updating code in one when I found the pagination for a publication library was not working.

    MarkupPagerNav was the same in both (image 1) 
    But the Dev version was different. (image 2)  3.0.173 was NOT paginating
    Pagination was working in the one with the older DEV (image 3) 3.0.172
    Until I updated that installtion to 3.0.173
    After the update it delivers the correct URL, but a 404 page (image 4) 

    I rolled back the update to DEV 3.0.172 (image 5)  and pagination is working fine...

    So... fixing this is above my pay grade ?

     
     

    Screen Shot 2021-03-11 at 11.12.46 AM.png

    Screen Shot 2021-03-11 at 11.28.52 AM.png

    Screen Shot 2021-03-11 at 11.29.36 AM.png

    Screen Shot 2021-03-11 at 11.37.18 AM.png

    Screen Shot 2021-03-11 at 11.42.07 AM.png

  10. I have a text field called tweet.  I'd like to display it:

    $tweet:  This is a sample tweet to @hollyvalero using a #hashtag, or #twotags

    and create a tweet button to convert that tweet as postable... I've removed the whitespace and replaced it with + signs

            if ($item->tweet) {
                    $tweetable = $sanitizer->removeWhitespace($item->tweet, ['replace' => '+']);
                    echo "<div class='twitterformatted'>{$tweetable}</div>";
                 }

    this gives me: This+is+a+sample+tweet+to+@hollyvalero+using+a+#hashtag,+or+#twotags

    in a link tag, the @handle works fine, but I need to replace the #hashtag with %23hashtag

    Trying to use a two-step approach with sanitize->chars but I don't see how to turn: $replacement = ''  into replace # with '%23'  ... 

             $hashtag = $sanitizer->chars($item->tweet, '%23' = '#');
             $tweetable = $sanitizer->removeWhitespace($hashtag, ['replace' => '+']);

    How do I word this?

  11. 22 minutes ago, adrian said:

    I'll admit I haven't really read your post - sorry, but I think this might do what you want based on the topic title
    https://processwire.com/api/ref/page/references/

    I’m looking for examples of how to use the page reference method.  It seems like that’s the way to go. 
     

    the page reference field is billcalendarbillref and it’s in the events records found. I need to match that field to the page title of legislation pages using the trackerplus template. 
     

     


  12. I have 2 templates: Legislation and Events

    Legislation template fields:
    billnum (eg 1234)
    billtype (eg SD, LD, LR)
    title  (An Act to Whatever)
    clients - a page reference field.


    We start with legislation of interest to a specific user who has tagged clients by role for that search string...and sort them by committee

    $user_roles_string = $user->roles->find('name!=guest')->implode('|', 'name');
    $bills = $pages->find("template=trackerplus, limit=600, client=$user_roles_string, sort=billscmte");


    And for each bill, we list clients which is simple since we prequalified them and that field is in this template:

    foreach ($bill->client as $c) {
      echo "{$c->title}";
      }
      
      
    On the Events template, we have a single page reference field that references the piece of legislation above, with a custom format label that brings in {billtype} {billnum} {title} 

    billcalendarbillref

    When outputting events, again, I use the user roles string to get the batch.

    $user_roles_string = $user->roles->find('name!=guest')->implode('|', 'name');
    $events = $pages->find("template=trackercalendarevent, client=$user_roles_string, sort=$cbdate2, limit=600,  cbdate2>=today");

     

    For each event I want to create a similar loop to list the clients, but I need to look up the legislation to find a match first - using just the prequalified group of events.


     // if there is a bill reference in the event item
    if ($event->billcalendarbillref->id) {    
     // locate the legislation page that matches the billcalendarbillref, get the clients listed, and print them out.
         $items = $pages->find("template=trackerplus,  title=$event->billcalendarbillref->title, limit=1");
              foreach ($items->client as $c) {
              echo "{$c->title}";
               }  

         }


    This doesn't seem right...Not sure how to word the match between [template:trackerplus, title] and [template:calendar, billcalendarbillref] ... I thought maybe I should be using 
    $items = $page->references(); but then got hopelessly confused...

    It's printing blank instead of an error which is a nice change of pace.   ?
    What am I doing wrong?
      
      

  13. 21 minutes ago, Robin S said:

    I take this to mean you want the names of the user's roles, excluding the guest role, as a pipe separated string that you can use within a selector string.

    One liner:

    
    $user_roles_string = $user->roles->find('name!=guest')->implode('|', 'name');

     

     

    That's exactly what I was looking for and it works beautifully!! Thank you so much!  I haven't done much with multiple roles per user... this is terrific!!

    • Like 2
  14. The set up:

    Lots of content shared by a variety of clients.
    To view data specific to one client, I've set up a role - Acme - and an associated template acme.php, so when the Acme user logins in, I can pop them directly to their Acme page where they only see Acme stuff. This works fine.

    That page loads various content pre-qualified by the client. I have the logins set to pop them to their page automatically.

    $bills = $pages->find("template=trackerplus,  client=$page, limit=200, sort=title");

     

    The challenge:

    I have internal users who manage several clients and want to see that same data but instead of visiting 3 pages, they want one page that lists all of the data for each of their clients only. I  can add the roles: Acme, MegaCorp, for each internal user.


    I want to do the same kind of content display, but I need to sort the content

    If user jsmith is associated with the roles Acme, MegaCorp
    if user kjones is associated with the roles Brown, United

    jsmith logs in and sees the client data dump for acme and megacorp only.

     

    The field: 

    Each content item has a multiple page reference field called client that I need to match to the roles of the user... and I need a list of names, not ids and trying various ways none of which are working...

    Assume I need to create a variable, and empty it out... then add the name for each one to the variable...

    $clientList = '';
    foreach ($user->roles as $role) {
         add $role->name to $clientList;
    }
    $bills = $pages->find("template=trackerplus, client=$clientList, limit=400, sort=title");

     

     

     

    Any assistance would be most welcome! ?

     

     

  15. Hi!  I'm experimenting with Ryan's RCDmap.js... got it all working but just wanted to use SVG images for the map markers. There's no class I can get... and #map .svg doesn't work. It seems like there should be a way in defining the icons to add something similar to 

        iconSize: [30,30]

    or google's map options:

          size: new google.maps.Size(71, 71),
          origin: new google.maps.Point(0, 0),
          anchor: new google.maps.Point(17, 34),
          scaledSize: new google.maps.Size(25, 25)

         Not having much luck... and yes, I can do very tiny png images but they are tend to get blurry on higher res devices. Not sure whether I should just try leaflet maps instead.

     

       /* The path to the icons folder */
            var path = '/site/templates/icons/';
            var marker = new google.maps.Marker({
                position: latLng,
                map: RCDMap.map,
                icon: path + cat + '.svg'

            });
     

     

     

    mapmarker.png

×
×
  • Create New...