Jump to content

DaveP

Members
  • Posts

    868
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by DaveP

  1. There are always multiple ways to achieve your aims in PW. What I tend to do for content shared across multiple pages is add a tab to the Home page in the admin using a new 'Fieldset in Tab'. Take a look in the demo admin at fieldset_meta. This way you can add all sorts of shared content and have it grouped together, images, site name, phone number, anything really.

    If things still aren't apparent after looking at the demo, come back here and ask some more.

  2. I tend to wrap more mark-up around than @fliwire, more like @MateThemes' original...

    <div id="offcanvas-nav" uk-offcanvas="overlay: true">
        <div class="uk-offcanvas-bar">
            <button class="uk-offcanvas-close" type="button" uk-close></button>
            <?= ukNav($home->and($home->children),array('depth' => 2,'blockParents' => array($home),'accordion' => true)); ?>
        </div>
    </div>

    $home is declared at the outset thus...

    <?php
    /* Declare PW namespace */
    namespace ProcessWire;
    
    /* Initialise some variables */
    $home = $pages->get('/');

    As is always with PW there are limitless ways to 'flay a feline'. (Although there are strong similarities.)

  3. This is great. A few years ago I worked briefly for a security company and one of my responsibilities standing in for the accountant when she was off, was billing for services (mainly door security - 'bouncers' here in the UK) and we used an online system very much like this.

    Some summary pages (monthly/yearly/all time totals etc) would be an obvious addition and tax liability calculations where appropriate perhaps. Of course, being built on top of PW, customisation should be straightforward on this kind of foundation.

    • Like 4
  4. You would need to create a role, say 'frontend_user' or some such. (Can't use 'user' because $user is a thing already.)

    Then do something like 

    if($user->hasRole('frontend_user')) {
      // show input form
    }

    See https://processwire.com/api/ref/user/has-role/

    Then https://processwire.com/api/ref/pages/add/ or https://processwire.com/api/ref/pages/new/ should help. You don't need to worry about database IDs and such - PW's API deals with all that.

  5. Nothing wrong with @bernhard's way of doing it, but another option might be to name templates like so-

    • blog_standard
    • blog_gallery
    • blog_short_status

    and set up fields within those templates as appropriate to its purpose. Then in the parent page's setting (Family tab) set allowed children to those templates.

    As with practically everything in PW there are as many different ways to do things as there are users.

  6. There's nothing to stop you having a (perhaps hidden) field 'index' on each month page representing the month's number, then your selector above would work (or very nearly work).

    If I was doing something like you are, I would probably have some code in _init.php or _ready.php or even at the top of a page template to programmatically create new 'year' and 'month' pages well in advance, creating and populating that 'index' field  as well and probably leave them unpublished so that they can be quickly and easily published when required. I think that would work. Probably.

    • Like 1
  7. A new tab isn't a new session - just like having PW frontend and backend open in different tabs - you stay logged into both, and any further tabs you might open. A new window might be (I haven't tested) but surely a user savvy enough to do that  will be savvy enough to expect adverse consequences (I would have thought anyway...).

    • Like 3
  8. I think one way of doing what you're looking for would be to do two finds - one for products and one for other pages and then merge them, because you need to override the 'organic' results somewhat, so you'll need to impose some kind of artificiality otherwise you'll just get what you're getting now.. 

    Say you want 10 results, get 6 products and 4 info pages (or 7 & 3 or whatever) and then rank that combined 10 by relevancy. 

    Another way would be to just always show say 3 products at the top, kind of like Google ads at the top of SERPS, but you wouldn't need to identify them as ads. Yet another way, on wide enough screens, might be to have a column for each.

    • Like 1
  9. On 7/30/2022 at 12:02 PM, taotoo said:

    Is this because I've made a PHP array, and it's the case that ->first only works with ProcessWire arrays?

    Yep, but, PW gives you methods for working with WireArrays - https://processwire.com/api/ref/functions/wire-array/. This way you can use ->first() or any of the usual methods. You'll need to refactor your code a bit but it might well be worth it.

    • Like 1
  10. Based on nothing but gut feeling, the second. That's the way I did it last time I was importing JSON from somewhere, mainly because I was glad to be able to stop thinking about the horrible JSON object and concentrate on nice PW fields. If you were going to be really careful, some benchmarking might be in order, but I suspect there wouldn't be much in it, just what you're more comfortable dealing with.

    • Like 1
×
×
  • Create New...