Jump to content

Inxentas

Members
  • Posts

    73
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Inxentas

  1. I've tried this, and put a $this->message() call in the hooked methods for now. They are not called at all. The pages are also not "installed" but created in the API like this: $admin = $this->wire()->pages->get("title=Admin"); $webshop = new ProcessWire\Page(); $webshop->template = "admin"; $webshop->title = "Webshop"; $webshop->icon = "cogs"; $webshop->parent = $admin; $webshop->process = $this; $webshop->save(); $orders = new ProcessWire\Page(); $orders->template = "page-orders"; $orders->name = "orders"; $orders->title = "Orders"; $orders->parent = $webshop; $orders->save();
  2. I'm developing a module that installs a couple of nested pages beneat the Admin page (and assigns the module as a Process to them). In the install method, I create these pages from top to bottom. In the uninstall method, I do the reverse and delete all children before deleting their parent page. However, I get the following error message: ProcessWire: ProcessModule: Can't delete Page 1563 because it has one or more children. This is strange as the script makes sure that isn't the case, as these are all deleted. Afterwards, their children are indeed nicely deleted. I've done a couple of checks. When I first delete all children, and use $message to print out $p->children()->count that returns zero, as expected. Yet $p cannot be deleted after confirming it's zero, because "it has children". Does anyone have any idea why? Extra information: Beneath the Admin page I create a new page called "Webshop" and assign my module as a Process to this page. This creates a button in the menu that leads to the primary admin interface of the webshop, for which I use a view. This all works nicely. The module installs a template named "orders" beneath this page, as I was planning to collect webshop orders beneath that one. In the uninstall method, I make sure to first delete all pages of the template "order" and "orders" before I attempt to delete the Webshop Process page. On an unintall attempt, I get above error message, but when I check whether the page it references (1563) indeed has children, these are indeed deleted in accordance with my code. Only the Webshop page remains, and it's Process is (logically) empty.
  3. Thank you, that worked flawlessly! I was a bit scared of manually updating 4 production sites this way, but I managed to complete the task without any real issues.
  4. Hi guys, I have a few really old sites that never received their updates. ProcessWire version 3.0.62. Now I can install the ProcessWireUpgrade module and run it, but I get some errors: Method AdminThemeDefault::getClass does not exist or is not callable in this context And that's logical considering how old these sites are. At the time we created them, Reno was the default Admin Theme. I have tried installing AdminUIKit by coping a (recent) module into /wire, which gave me another error. I've tried putting the module in /sites, same error. Error installing module - AdminThemeUikit Failed to construct module: ProcessWire\AdminThemeUikit - Method AdminThemeUikit::setClasses does not exist or is not callable in this context --- I have a feeling PW is trying to run a method on the current admin theme, which doesn't exist because it's only in the new admin theme. Can I somehow fix this and update the websites?
  5. For me the SMTP thing is not really negotiable, sometimes companies use some mail setup that requires it. I've used both PHPMailer and the module, and sometimes the module even wins out. Thanks for the "post-install-cmd" tip, that might work well for my situation... being that moving the vendor folder outside of the webroot isn't mission critical. I'm in that situation where I can do whatever I want, but I do have to work with 101 different mail clients and shared hosts so I prefer to add my most used packages to a new project by default. Thanks everyone!
  6. I took a look at the WireMail class and what I miss is SMTP support (although I might be wrong here, I simply didn't see anything in the docs that implies SMTP is supported out of the box). I could also use the module named WireMailSMTP for example, but no matter how you cut it that would involve installing the module manually for each website. It's preferable to me to manage dependencies with Composer and reuse our existing mail scripts, then installing PW modules manually for each project.
  7. Thank you, I found that article already though, and I found it to be a little messy of a process as well. On top of that I would like to use autoloaded stuff in my modules so that approach isn't super suitable for me. I have decided that for now, I'll just modify the existing index.php as that file won't change too often.
  8. Hello guys, I've started to implement Composer in my workflow more seriously and I'm looking for the best way to include more then just ProcessWire. We often use a few extra bits and bobs (such as PHPMailer) and I'm not sure how to best treat PW as a Composer package and how to get the vendor folder outside of the public folder. Now whether I do composer require or composer create project, I get PW as a full project including it's own composer.json and .lock files with it's vendor folder sitting next to the wire and site folders. Now I've done some experiments, such as moving the folder manually and changing the require statement in index.php, but that feels messy to me. I've also created a new empty project with my own folder structure, and then copied vendor/processwire/processwire into the public folder for installation, but I still need to faff around with PW's actual code. Is there a neat way to create a Composer project (or inherit the existing one) and use Composer commands to somehow get the vendor folder to sit once directory up from it's default directory?
  9. Yes, and that worked perfectly! Thank you @BitPoet. I was hesitant to change the .htaccess file but truth be told, this is kind of a legacy project, so in the end I did not do much research on what that would affect. Are there any PW related issues I should take into account? PS. I received a mail asking me to click a "mark as solution" button. I wanted to mark your reply as the solution but I'm not seeing that button. I fear I'm going blind.
  10. Hello there. I have an issue with a PW installation on some crappy shared host. A few days ago the site stopped working. So I checked the error logs, which said: Option FollowSymlinks not allowed here And logically, PW's .htaccess file says: Options +FollowSymLinks So it appears that FollowSymlinks is suddenly no longer allowed on this server. I rarely have to deal with server settings, but is the impression that PW simply needs FollowSymlinks to be allowed. Is this the case? Would it be valid to state that this server isn't suitable for a PW installation anymore, because the host no longer allows SymLinks? Would that statement be correct? I've never had the pleasure of a shared host suddenly no longer allowing SymLinks out of the blue, to be fair I am not entirely sure how those work. I can run the site on my local and test servers just fine: it's just this shared host that's been giving me grief for the last few days. The homepage could be reached but every child page just gave me a serverside 404 (not the 404 you'd expect from PW itself).
  11. I have a strange occurence which I have a hard time explaining/debugging. I have a module that contains a .JS file. I load this JS file using a hook, that is called when the template != admin... meaning it will only be called on the frontend. This works on my LIVE environment, but my DEV environment seems to decide to load the file somewhere. Since it contains a script that prevents scrolling, I cannot scroll in the admin. Is there a circumstance in which modules load JS files placed in their folder? Perhaps when it has the same name of the module under certain PHP versions?
  12. Ah, thanks a lot! I was trying to configure an InputfieldTextarea as one would do in the CMS itself and couldn't get it to render. Using the right class worked very well.
  13. Hello everyone, Is it possible to use a Repeater in module configuration? I can add one to getInputFields(), like so: // Source Repeater $field = wire('modules')->get("InputfieldRepeater"); $field->columnWidth = 100; $field->attr("id+name", "source_repeater"); $field->label = "Source Text"; $field->icon = "fa-align-left"; But I am at a loss as how to configure the Repeater further. For instance, I've tried making an instance of another fieldtype (FieldtypeText) and adding it to the repeater through code. I want to allow the user to add new entries in this repeater, but want to configure the Repeater field itself entirely through code. I want the admin to be able to add new Repeater items and fill them in. The module should decide what fields to use in the Repeater. When I add the Repeater code above to a wrapper it throws an error, I guess because it needs some fields or further configuration in order to be rendered. Is it absolutely required that I create fields, for instance in the install method of the module, or can I create them on the fly in getInputFields() somehow? How and where should I define the fields of this repeater? Thank you for your time!
  14. Hello everyone, I'm trying to write a module configuration by extending ModuleConfig. So far so good. I have a nice wrapper going with some inputfields. One of them is a TextArea that I've added as a field to my config class: $field = wire('modules')->get("InputfieldTextarea"); $field->columnWidth = 100; $field->attr("id+name", "source_text"); $field->label = "Source Text"; $field->icon = "fa-align-left"; I'm trying to make this a field that accepts HTML instead of plain text, so I want it to use CKEditor and set some options. I couldn't find how to configure that so I made myself a custom field through the CMS so I could take a look at how it's constructed. I figured out I could change it's attributes, but this doesn't seem to work: $field->attr("inputfieldClass", "InputfieldCKEditor"); $field->attr("contentType", 1); I'm a bit at a loss as to how I configure this field, since it's part of a module. I've also tried calling getExportData() on the field I made manually, which works and shows the relevant data, but I can't call setImportData() on the $field variable above: this causes an error. I guess because that field isn't saved in the database the way a normal field is. Can I configure module fields to support HTML?
  15. Super, thank you! I couldn't find it in the Process module documentation, but that makes a lot of sense. I'm almost embarrased ?
  16. My goal is to add a tab at the top of the admin named "tools" under which I want to install a few custom modules. For the Tools tab, I used a page with a ProcessList (so it visually looks like the Templates page). This works perfectly for superusers, but I cannot for the life of me find out how to allow other roles then the superuser to access these pages. I've tried allowing the "admin" templates to be viewed by these Roles, but that doesn't seem to work. Is this actually possible?
  17. Ha ha yes, I feel so silly because this isn't the first time this exact issue has caused me to look for the culprit for about an hour, to finally post on a forum in desperation... only to find the bloody typo just 5 minutes later! I'm alwats torn between blaming Windows / MacOS for not being case sensitive and exact enough, or myself for sticking with CamelCase. Thanks for understanding ?
  18. Typical. Just as I submit the topic, I find the solution. Turns out I just made a CamelCase boo boo with the filename: Defaultpage.php had to be DefaultPage.php. Sorry to waste your time.
  19. I seem to have some issues with the use of $config->usePageClasses introduced in ProcessWire 3.0.167. I've set it to true so I can use Page Classes. Works perfectly on my own machine, but not on my Staging server. I get the following error: Look out… Error: Exception: Method Page::renderHeading does not exist or is not callable in this context (in wire/core/Wire.php line 544) The method renderHeading() is part of the DefaultPage class. It seems the staging server ignores the classes entirely, as a var_dump() turns out the page is not of the DefaultPage class but the standard Page class. I have no real idea where to look for the issue, does anyone have an idea on how to debug this? The only difference between my Local machine and the Staging server is that it uses a different MySQL database to connect to. Here is the class in full: <?php namespace ProcessWire; class DefaultPage extends Page { /** * Renders a heading based on any title and an optional blurb. * * @param type $title * @param type $blurb * @return string */ public function renderHeading($title, $blurb = null) { $html = ''; $html .= '<div class="content"><div class="layout"><div class="intro"><div class="narrow">'; if ($title != null) { $html .= '<div class="big"><h2>'.$title.'</h2></div>'; } $html .= '<div class="divider"><div class="inner"></div></div>'; if ($blurb != null) { $html .= '<div class="blurb">'.$blurb.'</div>'; } $html .= '</div></div></div></div>'; return $html; } /** * Renders a Project page for the Collection Page grid. * * @param type $col * @param type $row * @param type $project * @return string */ public function renderProject($col, $row, $project) { $html = ''; $html .= '<div class="project project_'.$col.'_'.$row.'">'; $html .= '<a class="inner" href="'.$project->url.'">'; if ($project->image_header) { $html .= '<span class="background" style="background-image:url(\'' . $project->image_header->width(600)->url . '\')"></span>'; } $html .= '<span class="background" style="background-color:rgba(0,0,0,0.2);"></span>'; $html .= '<span class="inner">'; $html .= '<h2>' . $project->title . '</h2>'; $html .= '<div>' . $project->meta_description . '</div>'; $html .= '</span>'; $html .= '<a class="link" href="' . $project->url . '">View</a>'; $html .= '</a>'; $html .= '</div>'; return $html; } } When I add a specific class for the homepage and let it extend DefaultPage... <?php namespace ProcessWire; class PageHomePage extends DefaultPage { } I get the following error: Well well… Fatal Error: Class 'DefaultPage' not found (line 3 of site/classes/PageHomePage.php) It seems the DefaultPage class cannot be found/loaded.
  20. No, I simply moved them to a local directory, hoping that would be sufficient. Uploading them via the admin seemed to work, thank you! I'm still curious as to what is the difference (what uploading them via the admin actually does apart from storing the file). I could not find a "translation" system template, did you perhaps mean the language_files_site system Field? That one seems to have an option to allow for overwriting files.
  21. A client of mine wants his translations being done by an external agency. I've showed them the Site Translation Files and they can deliver me the required translations in the same JSON format. I went about it by first making some translation files for each language, so there's an ID and all the fields get an identifier. The intent is to give them the file, they change the content, and we place those files back. From there I've done some testing and it appears we could simply change the content of these files, as long as the JSON format is being respected. Whenever I changed something, the translation worked properly. So I sent a JSON file to the translator and had them translate the strings. There's no stuff in there that needs escaping so I figured this should work properly. At first they screwed up the values in the "file" and "textdomain" properties of the JSON object, but we fixed that. However, when I place the file in it's appropriate folder I get the following error: Fatal error: Uncaught TypeError: Argument 3 passed to ProcessWire\LanguageTranslator::textdomainTemplate() must be of the type array, null given, called in C:\wamp\www\bamboobrands.com\public_html\wire\modules\LanguageSupport\LanguageTranslator.php on line 485 and defined in C:\wamp\www\bamboobrands.com\public_html\wire\modules\LanguageSupport\LanguageTranslator.php on line 137 TypeError: Argument 3 passed to ProcessWire\LanguageTranslator::textdomainTemplate() must be of the type array, null given, called in C:\wamp\www\bamboobrands.com\public_html\wire\modules\LanguageSupport\LanguageTranslator.php on line 485 in C:\wamp\www\bamboobrands.com\public_html\wire\modules\LanguageSupport\LanguageTranslator.php on line 137 When I delete the JSON file the error goes away so I'm quite sure it's the file causing the issue. I did the following test: Deleted the language file and remade it via Find Files To Translate. Copied the file's content into a new JSON file. Overwritten the language file with this new JSON file. The same error occurs. I've confirmed with DiffChecker that the files are 100% identical. Somehow this issue only occurs when I overwrite the file. I seem to be able to copy-paste the data in, but using a different file causes above error. What could be causing this? Encoding maybe? I couldn't get the translator's file to work, but I could paste their work into the file. (I've told my client translation is an maintenance issue because his content will keep changing anyway. He is adamant that we do it this way, disregarding the fact that pasting in his translations would be less work then working around any coding issues. I know it's kind of stupid and error-prone to do it this way).
  22. I have a big collection of Pages with a template called page-product. These products have a few fields describing their properties. Now my client wants to split this template into various types of products, each with their own set of properties. The most obvious solution would be to make a few new specific templates, like page-product-foo or page-product-bar. Doing this would also mean rewriting a lot of existing selector logic. So what I could also do, is allow the client to append a child to the Product that has these properties. For me that would be a good solution, but for my client this might be confusing. So I'm looking for a user-friendly way to do the same. Ideally, these Properties should be filled in when editing a Page without having to mess with it's Children. One option is to make a Page with children for each type of product and make it a dropdown. And subsequently have each "property" field be visible only when a specific product-type is chosen. However, I'm not sure if this is the best way to go about it - since at the frontend I'd have to take these fields into account, and I'm not sure whether I'll be able to deduct in code which field should be shown (I guess this could be pulled from $fields->MyFieldName). Does anyone have a better idea on how to implement such a feature?
  23. Thanks guys, but I'm indeed aware how Google works ? and had hoped to find a less hacky way of doing things then straight up SQL. The weird this is that when I try to collect the language setting from a user via a selector and $pages, I don't get the actual field value - I get the value in the $user object instead. Something that works around this would also work well for me.
  24. I'm updating a website that is about a year old. The site has two languages: Dutch (default) and English. Now the clients wants English to become the default language. The site has a ton of translations already, so changing the default language in the backend is not really an option. So I'm looking for a way to simulate that behaviour, but in my experience doing it with redirects will lead to messy and unwanted behaviour. Can anyone tell me what the proper way of doing this is?
  25. Hi there! I am making a webapp where the admin can create Surveys, Questions and Answers. These are all Pages with a normal Parent / Child relationship. I want to prevent the admin from making changes to a Survey or it's children as soon as the submissions roll in. For that purpose I am using this code inside a hook, which basicly checks what template the soon-to-be-saved page is. I then find the proper Survey and check whether we have submissions for that Survey in an external table: public function testSave($event) { $page = $event->arguments('page'); $survey = null; switch($page->template->name){ case 'survey': $survey = $page; break; case 'question': $survey = $page->parent; break; case 'answer-choice': case 'answer-open': case 'answer-rating-1-10': case 'answer-rating-1-100': case 'answer-rating-likert': $survey = $page->parent->parent; break; } if ($survey) { $res = $this->db->query("SELECT * FROM submissions WHERE surveyId = " . $survey->id); if($res->num_rows > 0){ $this->error("There are already " . $res->num_rows . " submissions for " . $survey->title); } } } Works like a charm, with one exception. I do wish to prevent the page from being saved, but throwing an error doesn't prevent this. It doesn't seem to matter how I implement this in my module's init() method. These two lines of code have the exact same effect: the red warning appears, but values are still saved. $this->pages->addHookBefore('Pages::save', $this, 'testSave'); $this->pages->addHookBefore('Pages::saveReady', $this, 'testSave'); Is there a way to tell ProcessWire to NOT save the page when a certain condition is met? Thanks for your future replies!
×
×
  • Create New...