Jump to content

TomPich

Members
  • Posts

    101
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by TomPich

  1. Hello processwirers, My client has a quite specific need and I have no clue about how to handle it. Visitors can buy events ticket on this site, but they don't have a client account (that’s part of the spec). Once they bought their ticket, all data are stored in an external database. If they want to check their booking, they have to enter their e-mail in an input field. From there : Processwire send them a mail with a single use url When client go to this page (no password requirement, so url must be like a hash), Processwire retrieve from the external database all the info needed) and display it. The page is deleted after a while (let say 24h) to avoid excessive amount of pages (about 10.000 visitors are expected) I’m okay with fetching data in an external database. My problems are: how to associate the email address to the temporary page url? how to handle the "temporary" aspect of these pages? Any help/suggestions/clues will be greatly appreciated... 😅 Thanks
  2. Thanks! 😊 I’ll check if that solves my in the DefaultPage class.
  3. Hi there, I know there are several posts about this subject, but they provide the answer I’m looking for. I’m working on a website on which some data as to be read and/or stored in an external database (which is also accessed by another app). What’s the cleanest way to achieve that? My first idea was to exclusively use DefaultPage class. Something like: class DefaultPage extends Page { private \PDO $dblfa; public function __construct(Template $tpl = null) { parent::__construct($tpl); global $config; $this->dblfa = new \PDO("mysql:host=" . $config->lfa_dbHost . "; dbname=" . $config->lfa_dbName . "; charset=utf8", $config->lfa_dbUser, $config->lfa_dbPass); } public function getParticipants() { $request = "SELECT * FROM participants"; $query = $this->dblfa->query($request); $items = $query->fetchAll(\PDO::FETCH_ASSOC); $query->closeCursor(); return $items; } } But this generates some subtle bugs : in front: $pages->get(...some ID...) returns null (only when the DefaultPage class defines $this->dblfa, otherwise it works fine). in admin: one of the page, with over 300 children, returns PagesLoader: SQLSTATE[08004] [1040] Trop de connexions [pageClass=ProcessWire\DefaultPage, template=un_inter] (un_inter is the child template) So I want for this solution: In site/config.php $config->dblfa = new \PDO("mysql:host=" . $config->lfa_dbHost . "; dbname=" . $config->lfa_dbName . "; charset=utf8", $config->lfa_dbUser, $config->lfa_dbPass); In site/classes/DefaultPage.php class DefaultPage extends Page { public function getParticipants() { global $config; $request = "SELECT * FROM participants"; $query = $config->dblfa->query($request); $items = $query->fetchAll(\PDO::FETCH_ASSOC); $query->closeCursor(); return $items; } } It works perfectly, but it doesn’t feel “clean” for me. I’d like to handle all the external database logic in the same file (ideally DefaultPage.php as I will need to implement some methods, so init.php would not be the best in my very limited knowledge). Both solutions actually fetch the data, no problem with that. Anyone to shed some lights about that? Thanks guys.
  4. Hello, I would create a template with the sidebar content fields (without PHP file associated, as it is not intended to be displayed as a page), and create a page (let’s call it sidebar-page for our discussion) with this template. Then, in your post template, just call the content of your sidebar-page, something like $sidebar = $pages->get({sidebar-page-id}. Then you can use any field of this page in your post. Hope my explanation is clear enough... 😊
  5. Hi @mel47, I would split the string with duplicate dates into an array, then use array_unique to get rid of them, then join the array into a string
  6. Welcome @floko, I don't really get your problem. What is the link url you’re supposed to get when using contact persons? What is the response code of this blank page ?
  7. Hello @dan222 and welcome to this forum! To push a site online : go to your db manager on laragon and export your db as a sql file then, from your hosting control panel, create a db (or empty it if it already exists) and import your local db with FTP, copy your local files in your hosting folder for your site (don’t forget to change the database config in /site/config.php file) And that’s all. ? Now, you can be a bit more efficient by using an "if" statement for your database config, so that you don’t have to worry about changing them when you push your site online (see below) using ssh/rsync to synchronize your local and distant files I’m sure you can optimize database export/import too, I didn’t dig in yet... // db config online / on localhost if ( $_SERVER["HTTP_HOST"] === "my-online-url.com") { $config->dbHost = '...'; $config->dbName = '...'; $config->dbUser = '...'; $config->dbPass = '...'; } else { $config->dbHost = 'localhost'; $config->dbName = 'my-local-dbname'; $config->dbUser = 'root'; $config->dbPass = ''; } $config->dbPort = '3306'; I generally need 4 minutes to pull or push a website after or before working on it, if it involves db update. If it’s only changes in files, it’s done in 10-15 seconds.
  8. Hey @JCVinso, Your admin looks perfectly normal. You see all the pages of the website. From there, you can edit them (hover → edit button). Can you explain what do you want to achieve? What can of options do you expect to see in the admin?
  9. I also like to give my clients some links to articles about PW : Article on PW by IONOS Article on PW by London web agency Net Dreams Article on PW by British web agency Presto ProcessWire vs WordPress on cmscritic.com And nice websites built with PW : Australian Antartic Program Nienburg Mittelweser Peggy Guggenheim Collection Herzzentrum Bonn Austrian Bankers Association BMW Dealersites University of Florida / IFAS Assessment and hundreds of others on this page.
  10. Thanks @Neue Rituale, I’ll try that right away.
  11. Will definitely try this module ?
  12. Hi @d'Hinnisdaël, Just wanted to say (again) how awesomissimo is your module. It’s a real asset in the scale when trying to convince a client to switch from WP to PW. They often fear to be lost with a new admin interface. But thanks to Dashboard, I can demonstrate how easier it is. ?
  13. Hi guys, I was wondering if the action buttons for each page in page tree could be : All always visible (always immediately see Hide, Unpublish, Trash... when hovering over page link) Hidden selectively even if the action is possible (like always hide the Lock button) About the Add new button, I noticed something that is a bit weird : Let say I have a P template that may have children based on template C1 and C2. C1 and C2 can only have P as parent. So these conditions are enough to get a link with the "Add new" button, and it works perfectly. Now, let’s imagine I have two roles defined : chief-editor and contributor. Chief-editor can create pages based on C1 and C2 and can see both "Add new" links. Contributor may only create pages based on C2. They should only see "Add new C2" link. But they actually can see both links, and when they try to create a C1 page, they get an error saying "ProcessWire: ProcessPageAdd: Template page-post is not allowed here (/p-page-url/)". Which is absolutely right, as they are not allowed to create C1 pages. But it’s confusing for the user. Did I misconfigure something here? Or is it something that should be fixed?
  14. Very old indeed, but still useful... and still working ? Who said plugins needed to be updated every week ? Oups... wrong forum... ? I’ll open an issue on Github.
  15. Hey there, I had the same need (hide page tree for certain roles). Used https://processwire.com/modules/admin-restrict-page-tree/ module. Worked like a charm, except that I had the same problem than @DL7, i.e. the bread crumbs provide links to the page tree. The page tree is not displayed, but a page saying "Login" with an "Edit profile" button is shown. That may be a bit confusing for users. So I add a few lines to the module, in order to optionnaly skip the bredcrumbs rendering (a hook, and a checkbox to choose whether you want to display the page tree for restricted users). It works well with AdminThemeUikit (I didn’t test it with the default admin theme). I thought this might be useful to other users. @Wanze, @netcarver if you want to have a look at it, maybe for module update? It would be my first contribution to a PW module... ?
  16. Sounds great. It would cover my needs. Do you treat these users as PW users? Or did you make a kind of "front user" profile using a custom template? In the last case, i wouldn’t be so sure on how to handle security matters and sessions.
  17. I just wrote a first draft of the precise specifications... And gosh, that would be a tremendous work to do with a framework. So, I think, as you all pointed, that it would be better in terms of cost/benefit, to use PW admin. This project has no profit objectives. They want to raise funds by donations and crowdfunding for the website. I thus have to offer them the best cost/benefit ratio (end still pay my bills at the end of the month ? ). The design is not that important. But most users won’t be tech-savvy. So it has to be simple and straightforward. That being said, I didn’t explore how to twitch the admin theme in PW (that was next in my PW ToDo list). It would be a great occasion. I recently thought about using exclusively the Dashboard module for some restricted user accounts in a website I’m doing – and I don’t even know how to do that. Any suggestion about tutos and posts that could help me explore this aspect of PW are very welcome (I took note of your YouTube video, Bernhard, and will watch it ASAP). Thanks guys, as always, for your help and your time. Much appreciated. ❤️
  18. I agree, users must not use PW backend. I was thinking of a custom backend (my account / my ads / CRUD for each ad) and then use PW API to manage that. I recently dived into the page / template / field management API, and it’s quite simple and straightforward. And I also agree, JS is not necessary – it’s just for things to be smoother and nicer, like an AJAX search result display. You are right about GDPR. I need to investigate a bit more about that. So if I got you right, you would go with a from scratch PHP backend ?
  19. Hi guys, I might have an interesting project in the coming months. For now, I have to give a quote for this job. The project is a website where different kinds of users could post ads about pets for adoption or for sell. This means that I must be able to handle hundreds of users with an account (three different kind of accounts : private, association and animal professionals) and hundreds, maybe thousands of pets. My first thought is : PW + AlpineJS. I read that PW is capable of handlings hundreds of thousands of pages. I begin now to be quite familiar with PW API, and AlpineJS would let me bring some interactivity. My second thought : PW headless, acting as a REST API provider, and Svelte for the front end (I never used Svelte, but it seems nice and quite light weighted, it would be an occasion to learn on a real project – I learned a little bit of React but never had the occasion to use it for real projects). I’m afraid Svelte would be a bit of an overkill, I don’t really need advanced reactivity and all that. But it could be a way to broaden my horizons. My third thought : Laravel for backend (never used it – I’m a bit familiar with Symfony, but Laravel seems more light weighted). The publishing needs are not big : create an account, publish a pet file. And that’s it. So maybe (maybe !) a PHP framework would go straight to the point. I could even develop it from scratch, but I don’t trust myself 100% about security. What would be your choice ? Any clue about the time you would need to do that ? My guess is about 80-100 h for the first solution. I am very eager to hear some experienced guys' opinions... Thanks in advance.
  20. For my first steps with PW, I found this Youtube playlist by Henning Heyne. He builds step by step a simple blog, but by doing that, you get to grasp some concepts of PW that maybe a bit not intuitive but prove afterward to be extremely powerful (like a simple post category being a page in itself). Hope that will help.
  21. Hello @Neue Rituale, I’m exploring your module possibilities. It seems very useful. I can’t figure out something though. I’m sure it’s very simple. Let say I have a ptn field in my homepage. I defined a template (named "section") to be used with this ptn field as an element. In the php template file of this section, how can I display the section title ? If I write $page->title, I get "Home" (so the title of the page where the ptn field lives), instead of the section title itself. Said in another way, the $page variable is not scoped to the element template. It’s always scoped to the page template. So how can I catch the field value of the element templates? Any help would be greatly appreciated. Thanks PS: for custom CSS, it seems that, because of the shadow DOM, the CSS custom properties like --bg-color scooped in the root of the page are not defined when used in the shadow DOM.
  22. Thanks @gebeer This RockMigration module seems really interesting.
  23. Thank you guys. You are amazing. I prefer not to use modules when what I want can be achieved with a few lines (this is an old habit I got with WordMessPress). I’ll try your suggestions. And I’ll investigate about this MagicPage. I read this name three times yesterday and I have no clue about what it is.
  24. Woaw... Even simplier ! I didn’t know about the Page::changed hook. ? Thanks Bernhard. EDIT: I just realized that, in my use case, it wouldn’t be enough. I don’t want to execute the logic if the field has changed, but [IF the field has changes AND the new field value is true]. But still, this hook is great and may cover 90% of use cases.
  25. Even if you enter that manually : "sameAs" : [ "https://www.facebook.com/company", "https://www.instagram.com/company", "https://www.linkedin.com/company" ] the browser still skips the line breaks (as shown in the console). I guess you can’t override this behaviour.
×
×
  • Create New...