Jump to content

DrQuincy

Members
  • Posts

    252
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by DrQuincy

  1. Thank you. I totally agree with you but…

    The reason I'm doing it this way is I'm using the https://github.com/Toutouwai/CustomAdminMenus plugin — and this is unaware of page permissions.

    EDIT: I've realised this will do the job. It's not quite what I was after but it's a bit of an edge case anyway and only takes a minute to implement.

    wireLangReplacements([
    	
    	'The process returned no content.' 	=> 'This page is either for administrators only or it doesn’t exist. Please go back and choose another page.',
      
    ]); 

    Thanks for your help.

    • Like 1
  2. Thanks for the suggestion.

    It's slightly different in this instance since there are additional items in the admin that appear in the menu, which I can't remove, and it would just make it look like they're broken if they 404. I was hoping instead to simply override the text of these to make the user experience make more sense:

    1. ProcessWire: You don't have access to edit
    2. The process returned no content.

    Even something as simple as a translation would be better:

    1. You don't have permission to view or edit anything on this page
    2. This page is for administrators only. Please click here to go back to the main admin page.

    Is that easy to do?

  3. That's really good, thanks for the suggestions! I'm going to keep that as a potential way. I like it, thinking outside the box. 🙂 

    My somewhat liazier solution is simply to add a field to the user template: Legacy, Legacy converted, and New. If A Legacy user attempts a login it simply sends them to the password reset page. And when they do they become Legacy converted.

    Your way is far slicker so I'll present the client with both options.

    • Like 1
  4. I have an old custom site I built myself where the passwords are hashed using BCrypt.

    I'm assuming the answer is no due to the one-way nautre of hashing but is there any way to take my bcrypt-hashed passwords and import them into PW? Where as my passwords stored the BCrypt strength, hash and salt together, PW seems to store the hashed password in two parts.

    I think it's further complicated by the $config->userAuthSalt value (this looks more like a pepper to me).

    It can't be done, can it?

    In which case, will just have to copy the emails, etc across into PW and send them each an email asking they set a new password or display a message on the website if a legcay email is used to attempt a login.

  5. Oh wow, you are amazing, LOL!

    That worked great. The only downside I can see if that I can't see a way of having a dynamic number of rows in the Google Doc. So I have to paste more than I need for the update to work. E.g. If I paste 10 rows in the Doc that limits it to 10. That should be okay but am I missing something that would allow me to have any numbers of rows pull through?

    • Thanks 1
  6. Hi all,

    This is nothing to do with PW… I have some data in Google Sheets. Do you know if it's possible, ideally without having to use their API, to create Google Docs that automatically feed in data from certain sheets/cells.

    E.g. A Google Sheet has a list of addresses that have address in one column and a “type” flag attached to them (e.g. rural, suburban, urban). Let's say there are 3 x types as mentioned. Is it possible to have 3 x Google Docs that feed in addresses filtered by type? And, ideally, if the data is updated in the Sheet it automatically progates into the Docs.

    Can this be done? I have had a look but can't find anything. It looks like they have a decent enough API but it looks like it would take more work than I have time to spend on it.

    Thanks.

  7. When you access an image from the API you can get the width and height with $imade->width() and $image->height(). When you run these internally does ProcessWire get the sizes from the database or does it actually use GD to get them? I'm assuming if you aren't creating variations on the fly it just reads them from the database (the schema has width and height columns).

    Just checking that there won't be any significant overhead if doing this on lots of images.

  8. I have a site that has a parallax fixed banner at the top and then the rest of the content goes underneath with a higher z-index.

    It works great but when — on a Mac at least — you scroll quickly down to the bottom of the page it scrolls beyond the height of the document body and then snaps back and for a breif moment you can see the fixed banner underneath.

    Is there a CSS property to prevent this?

  9. I want to get an external display for my new 24" iMac. I don't want something huge but I want it to be retain display. It seems like most monitors out there are either about the size I want (20"–24") but they are “full HD” (only 1080). Or 4k, which is a better resolution, but the screen sizes are huge!

    Without getting an Apple Studio Display or LG Ulttrafine, does anyone know if a 20"–24" display that is also retina?

  10. I've got this code:

    $field = wire('fields')->get('mySelectOptionsField');
    $options = $field->type->getOptions($field);
    
    echo $options->first()->title;

    The echoed statement is not HTML-encoded. However, when you get select titles from $page rather than from $fields the title is HTML-encoded.

    I get that this is intended behaviour. I just wanted to check:

    1. When in the front-end and using the API is the general rule anything you get via $pages or $page has of set to true by default but anything else — such as my example above — there is no output formatting since that only applies in the context of pages
    2. Is there an in-built way to HTML-encoded from $options as above — or should I just used $sanitizer->entites()?

    Thanks.

  11. Interesting, you learn something new every day! I'll bear that in mind for next time.

    I think I was put off by this:

    Quote

    As you can see, there are a lot of potential pitfalls, so use care with multi-instance. However, we suspect many will be using multi-instance simply as a way to pull data in a read-only manner, and in that context you shouldn't have to worry about much.

    Since I was reading and writing quite complex models I was more comfortable using JSON and sharing data that way.

  12. I believe bootstrapping for when your other script is not already a PW instance, including command line (I have used that on a project before, by the way, and it's very useful and easy).

    With the multi-instance option, due to the PHP namespace, you can only write to the main instance. You can read from as many others as you want but you can never save anything as when you run new \ProcessWire\Page you are always creating a page in main instance's namespace. In my case, I needed to read from the main instance and write to the secondary one so it wouldn't work for me.

    At least that's how I understood it! I couldn't see anything in the doc that allows you to create new pages in secondary instances.

  13. I have a Table field that I am using for some spam filtering. I have one field in the table set as a Text field. If I enter <a href=" and save it becomes blank regardless of any text formatters applied.

    It's weird because if I do the same with a Text field that is not part of a Table field it works fine. And within the Table field if I change it from Text to Textarea, it works.

    Any ideas why?

    Thanks.

  14. The client basically has two sites. One is in the UK and the other in the EU but serves customers internationally. There is a lot of shared information on both sites but at the same time they are different enough to warrant individual sites. But the client didn't want to, for example, add (and keep up-to-date) the same product twice.

    What I have set up is a root site that doesn't have a front-end but stores all the shared data. Then there is a folder for each site within that, each a separate PW instance.

    /root/
    /root/uk/
    /root/eu/

    My question above was really to see if I could copy info between the sites within the same script. While Robin S's link was useful, it would appear to be for read-only so I didn't end up using it.

    Instead, the root site has hooks that saves all data into JSON files and associated assets and the EK and EU then take the and convert it to PW pages.

    If you're wondering why the EU and UK sites are within the root site folder as opposed to being siblings, it's because they share the same templates, models, JS, SCSS, etc.
     

    • Like 3
  15. If I had sites A and B is there a way in site A to create an instance of ProcessWire\wire() that is connected to a completely different site? The reason I ask is to sync some data between two different sites on the same server on the fly.

    E.g. on site A:

    $page1 = wire('pages')->get(/foo-bar/);
    
    $page1->of(false);
    
    $page2 = new \ProecssWire2\Page;
    
    $page2->template = $page1->title;
    $page2->title = $page1->title;
    // and so on
    $page2->save(); // Saves to site B

     

    • Like 1
×
×
  • Create New...