Jump to content

Search the Community

Showing results for tags 'count'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 10 results

  1. Hi all, Just wondering if anyone else has encountered this issue. During some work recently I have noticed that it seems like when you use count() on a repeating field to determine if theres any content to output, it works fine on a template but behind the scenes as part of a module it doesn't return the same results on the same data set. For instance. On the frontend template this outputs as you would imagine: Doing a count on that same field, from within a module I get count() returning as 2, which makes sense as both are enabled. However I noticed that, if I then disable one of the repeating items, ala: This is reflected in the frontend as you would imagine, like so: However within the module logic, the value of count() on the same data set will still return as 2 The fact that I can't rely on the count within the module being correct is having major knock on effects as I have no idea whether to trust any information brought back about that repeating field. Does anyone know a way to get a correct number from a repeating_field->count or count(repeating_field) from the API, that actually takes into account the enable/disabled status of the elements within it? I have tried using various methods which are fine on a page template but just seem unreliable in my modules context, for some clarity, this is how I am pulling out the same field via the module: $overrides = $this->pages->findOne("template=plot, parent.id="666", title=plot 101"); then the following to check if there any content within the repeater error_log('COUNT:'.count($overrides->key_features)); For the record the following also appears to be giving the same as above error_log('COUNT:'.$overrides->key_features->count); So presumably this is a bug or COUNT() works diffferently between use in templates and usage with the API? If its working as intended, can anyone point me towards some documentation that explains the differences? Any thoughts would be much appreciated?
  2. I'm getting the following error. Having posted it in the GitHub I realise I should post it here instead. Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/domain.com/httpdocs/site/assets/cache/FileCompiler/site/modules/MarkupSEO/MarkupSEO.module on line 245 I know MarkupSEO is an old and relatively discontinued Module these days but was hoping to fix by upgrading both PHP and PW to latter versions. I am now running ProcessWire 3.0.148 © 2020 and PHP 7.3.13 Issue persists.
  3. From my last post, I was given a good idea on how to count the repeater items, and it worked wonderfully. I got my code working well and the columns (based on the count) all work well as well. Now, I have a head scratcher on my hands. <?php $buttonsIncluded = $page->special_custom_buttons->find('special_custom_buttons_include=1'); $buttonsIncludedCount = count($buttonsIncluded); $buttonsIncludedCountAdditional = $buttonsIncludedCount +1; echo $buttonsIncludedCount; ?> <div class="row"> <?php foreach($buttonsIncluded as $button): ?> <?php if($button->custom_buttons_include): ?> <?php if($buttonsIncludedCountAdditional == 2): ?> <div class="col-6"> <a href=""><?php echo $button->custom_buttons_text; ?></a> </div> <?php elseif($buttonsIncludedCountAdditional == 3): ?> <div class="col-4"> <a href=""><?php echo $button->custom_buttons_text; ?></a> </div> <?php elseif($buttonsIncludedCountAdditional == 4): ?> <div class="col-3"> <a href=""><?php echo $button->custom_buttons_text; ?></a> </div> <?php endif; ?> <?php endif; ?> <?php endforeach; ?> </div> All of this is included in a larger foreach statement that is pulling in other data (like body copy etc etc) from a Page Table field. As you can see in my code above, I am adding "1" to the count, so I can have space in the grid layout for a new button. So, right now: it looks something like: [repeater button] [repeater button] [repeater button] [space for new button] What I really need to do is to pull in the button from the Page Table and add it into the new space so it looks like: [repeater button] [repeater button] [repeater button] [button from Page Table] Is this even possible todo, or is there a better way to go about this? *Edit* So, I really just overlooked something quite easy here. Since the grid is based on 12 columns, I could just take 12 and divide by $buttonsIncludedCountAdditional which would give me the remaining col width to use outside the foreach loop. I was trying to make this too complicated.
  4. Is it possible to use count() to return a number of repeater items don't have a checkbox checked? In my current set up, I have a repeater on the page "dev_repeater" with a checkbox called "dev_repeater_exclude". I need to get a count of the current items that do not have it checked so I can pass it to my css grid to alter the column width.
  5. Reference: PW 3.0.62 and uikit3 based site using the Reglar-Master profile. I'm trying to add a count of the number of category posts to display beside each of the category titles listed in the sidebar on the blog page. The following code displays the total number posts on each category page: <span class='uk-text-muted'>Total <?php echo page()->title; ?> posts: <?php echo count(pages()->get('/blog/')->children("categories=$page")); ?></span> The following default code displays the heading and a list of the categories: <?php $categories = pages()->get('/categories/'); echo ukNav($categories->children, [ 'header' => $categories->title ]); ?> but I want to add the respective number of posts on the same line as each category title listed. When I try replacing the default code with the following: <?php $categories = pages()->get('/categories/'); $catposts = count($categories->children("categories=$page")); echo ukNav($categories->children . ' ' . $catposts, [ 'header' => $categories->title ]); ?> I get the following error: which refers to the following code in the _uikit.php file: $page = $items->wire('page'); // current page and when I try: <?php $categories = pages()->get('/categories/'); $catposts = count($categories->children("categories=$page")); echo ukNav($categories->title); foreach ($categories as $category) { echo $category->children . ' ' . $catposts; } ?> or: <?php $categories = pages()->get('/categories/'); $catposts = count(pages()->get('/blog/')->children("categories=$page")); echo ukNav($categories->title); foreach ($categories as $category) { echo $category->children . ' ' . $catposts; } ?> I get the same error. If I change to I get the following error messages: Any advice on where I am going wrong would be very much appreciated.
  6. So maybe has already figured this out, but I am stumped. I have a field (test_field) that is set to pdfs, and I was trying to get a count of the number of pdfs in that field so I could add it to a status bubble on the front end. I tried: function testPDF() { $a = $page->test_field->count(); echo "<span class=\"bubble\">" . $a . "</span>"; } but it is returning "NULL" . I currently have 3 added to the field. I also tried putting this function in _func.php, though I need to use wire('pages'), but I only need to get the count for that specific page, so I am sort of at a loss of how to proceed.
  7. So I have a bit of code for ad management : <?php $ads = $pages->find("parent.template=client, sort=expiration_date"); $alert_count = 0; foreach ($ads as $ad) { $todaysdate = date("F j, Y H:i"); $today = strtotime($todaysdate); $expireson = $ad->expiration_date; $expires = strtotime($expireson); $fiveaway = $expires - 432000; if ($today > $expires) { $alert = $alert_count=+1; echo $alert; } } //end FOREACH ?> It currently finds all the pages with a parent of "client" and then I can drill down to the pages that have "Expired" in my if statement. I wanted to get a "count" of the pages that met the if statement requirements so I could output that number in an alert at the top of the page. When it runs, it currently just prints out "1 1 1 1..." and not the total count of pages. Does anyone know of a way possibly achieving my desired output? I tried count(), but that did not quite produce my desired output. I should note that I have several other if statements dealing with the date/time for outputting other alerts as well (just didn't think they were needed for this case).
  8. Hello again everyone, I'm creating a template with an easy-to-use front-end adminbar (basically says: "Edit Page", "New Page", "Add News", "Add Product") and to make it more "user-friendly" it has the editor avatar and name as well as the options for "Profile, Help and Logout". I wanted to use PW's Comments Fieldtype and found that it's possible to display comment count here: http://processwire.c...rns-odd-number/ and I also found that it's possible to check comments since the last visit here: http://processwire.c...nce-last-visit/ I am now wondering *if* it's possible to display the total comment *count* from all pages containing the 'comments' field. Basically like this: "Welcome Back admin, there are {$comment-count} new comments." and that would redirect to the Comments Manager module. I've looked around the forum but didn't find anything similar, and I'm not really good with PHP so I might've overlooked a function. Thanks in advance. EDIT: Can I use something like: $count = count($comment) ?
  9. Hi folks, I am trying to create a counter for items within a section... so say you have a Projects section, on each 'project detail', I'd have a counter and it would say this is page 1/25, for example. I have the total count, but I'm not sure how to echo out which position/number the current page you are viewing is. <?php echo $page->eq() ?> / <?php echo $page->parent->children()->count(); ?> Any thoughts? Thanks!
  10. Wondering if anyone has made a way of displaying filed content of pages on the page list (or another admin page / sidebar). For example: an indication of new page comments displayed on the page list. a count of the number of photos for each page that hows photos. Mock up:
×
×
  • Create New...