Jump to content

DaveP

Members
  • Posts

    868
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by DaveP

  1. Easy. See 

    Then have a field in that page for owner, which is the user's $user->id, add ?edit=true to the url (in a link from a user page or whatever)  then in the page template something like

    <?php namespace ProcessWire;
    
    // Code to display page contents to guests
    
    if($input->get->edit && ($page->owner != $user->id)){
      echo 'You are not authorised to edit this page.';
    } else {
      // Your code (edit form etc) here
    }

    Very rough, but you should get the gist.

    If you get stuck, come back here and ask.

    • Like 2
    • Thanks 1
  2. It is actually simpler than it looks, you just have to be brave! And use a disposable local install of PW, just in case you blow it to smithereens. (I'm joking of course, so long as you leave /wire/ alone, there isn't much damage you can do.)

    It's a fantastic feeling of achievement seeing your own custom page in the PW backend.

    On 11/7/2017 at 10:28 AM, arjen said:

    This should be highlighted as an USP for ProcessWire.

    @arjen is quite right. The extensibility of PW's backend isn't something you see mentioned in reviews etc.

    • Like 3
  3. It's only a hunch, but you're using $session->password. Password isn't normally a property of $session (it's a property of $user), so there's a chance that the $session object is being messed up by your setting it like that.

    Try renaming that variable to something like 

    echo "<br><h1>session[password] is </h1>".$dasession->password;

    so that the $session isn't affected and see what happens.

  4. I *think* you could replace the field in the user template (a user is a page, right?) with a repeater or a PageTable (best bet) and use this to store references to 'reactions'. These being pages, could then contain fields for image/page id, kind of reaction (like/share whatever), and that the image poster has been notified of that reaction.

  5. 3 minutes ago, abdus said:

    In short: it's not trivial. Or I'm making this complicated in my head.

    Absolutely right, it's not trivial and it can very quickly become properly complicated.  @abdus has very quickly pretty much nailed my current thinking on this kind of functionality.

    I'm currently working on just such a system (with the added extra of location-aware messages), but by breaking it down into manageable bits (I'm hoping) it becomes feasible. 

  6. This is odd - I thought I'd replied to this thread on Monday but there's no sign of that post. (Has there been a problem?)

    Anyhow, I accepted & merged @netcarver's pull request, thanks for that.

    And I think going forward that making the module configurable so that a selection of text files can be chosen from might add to its usefulness.

    • Like 2
  7. @netcarver has already forked my module and when I figure out how, I will pull (some of) his changes into mine. Anyone else is welcome to fork and create pull requests.

    For example, @horst's suggestions could be quite easily incorporated - it could also be made configurable so that different dummy text source files could be selectable, but that would be stretching my skills somewhat, so I would welcome others' input.

    • Like 2
  8. 2 hours ago, bernhard said:

    you know my dummy data module? 

    It's hard to keep track of these great modules!

    4 hours ago, psy said:

    It's so easy to use and saved me heaps of time copy/pasting from lipsum.com

    That's exactly why I made it. Thanks.

    On 10/6/2017 at 3:47 PM, abdus said:

    Can you add a randomization logic?

    Just committed changes to enable pretty much exactly what you asked.

    Tags now work like this -

    • [dc3] - Show 3 paragraphs ([dc:3], [dc3p] & [dc:3p] all do the same). (Same as original functionality.)
    • [dc3-6] - Show 3 to 6 paragraphs randomly per page load ([dc:3-6], [dc3-6p] & [dc:3-6p] all do the same). (New stuff.)
    • [dc3w] - Show 3 words ([dc:3w] does the same). (Same as original functionality.)
    • [dc3-6w] - Show 3 to 6 words randomly per page load ([dc:3-6w] does the same). (New stuff.)

    (Anyone who has already downloaded and is happy has no need to update - the only changes are in response to @abdus's request above.)

    • Like 4
  9. I just made a textformatter module that allows you to insert dummy content (lorem ipsum style) in text fields via shortcodes.

    Usage is simple - just type for example [dc3] into a textarea with this textformatter applied (plain textarea or CKEditor) and it will be replaced at runtime by 3 paragraphs of dummy content. It can also be used to populate text fields (for headings etc) using e.g. [dc4w]. This will produce 4 words (rather than paragraphs) at runtime.

    The actual content comes from an included 'dummytext.txt' file containing 50 paragraphs of 'Lorem ipsum' from lipsum.com. The 50 paragraphs is arbitrary - it could be 10 or 100 or anything in between, and the contents of that file can be changed for your own filler text if you wish.

    The slightly clever bit is that for any given page, the same content will be returned for the same tag, but the more paragraphs available in 'dummytext.txt', the less likely it is that two pages will get the same content (very roughly speaking - it's actually based on the page ID) so content selection is determinate rather than random, even though only the tags are saved to the db.

    Update

    Tags now work like this -

    • [dc3] - Show 3 paragraphs ([dc:3], [dc3p] & [dc:3p] all do the same).
    • [dc3-6] - Show 3 to 6 paragraphs randomly per page load ([dc:3-6], [dc3-6p] & [dc:3-6p] all do the same).
    • [dc3w] - Show 3 words ([dc:3w] does the same).
    • [dc3-6w] - Show 3 to 6 words randomly per page load ([dc:3-6w] does the same).

    <End update on tags.>

    If you think it might be useful, you can download it from GitHub and give it a try.

    • Like 13
  10. One fun way of demonstrating a real difference between PW and WP is to run the average WP site (preferably one chosen by the (prospective) client) and an equivalent PW site (probably from the showcase) through a tool like YSlow.

    WP sites often have all these plugins, often including multiple different versions of jQuery etc etc. I just tried it on a WP site I know of and got this

    59ca1bd9d7ffa_ScreenShot2017-09-26at10_16_18.jpg.822b772e21a7892bdd23a8e13ba7add2.jpg

    Yep, 28 external javascript files and 23 external stylesheets. That's, what, 40-odd unnecessary requests?

    Doing the same thing on a similar looking site from the showcase wasn't perfect - 6 js and 3 CSS (AIOM, anyone?), but it's actually a really obvious way of explaining even to a layperson that one way is very obviously better than the other - file conflicts, bandwidth, load time etc.

    • Like 3
    • Thanks 1
  11. 38 minutes ago, szabesz said:

    this new module (LoginRegister) should be in the core

    FWIW, I respectfully disagree.

    For a lot of sites, it just isn't required. Maintainers can log in through the admin and a whole host of sites just don't need front end user management. It always struck me as silly that some other CMSs always have (had?) a visible login link on every page.

    If it's a concern that it might be a harder sell to clients that this isn't part of PW core, then surely the fact that Ryan is the developer should confirm that this is effectively 'part of PW', just not installed by default.

    As far as security goes, and misjudged editing of modules vs core files, there will always be people who go fiddling about in /wire/ when they shouldn't, so this functionality living in there won't necessarily help.

    • Like 1
×
×
  • Create New...