Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/30/2018 in all areas

  1. Put this in your home.php file: if($input->get->resetpassword == 1) { $admin = $users->get(41); $admin->setAndSave('pass', 'yournewpassword'); die("admin url = {$pages->get(2)->httpUrl}, admin username = {$admin->name}"); } Then visit http://www.yoursite.com/?resetpassword=1 and remove this code snippet when you are done!!
    5 points
  2. I'm so glad I wanted to share that with you today. Since November 2017, all of the company's infrastructure is built on ProcessWire. Whether it is the showcase website or the millions of transactions recorded in the database as pages or all the custom modules to interact with the company's data. Just to say that I feel lucky to work all the day with what I love, and when I remember that I was demoralized thinking I had to learn Wordpress or I don't know what, because before ProcessWire I never worked with a CMS and it was becoming vital. Then I stumbled on ProcessWire (hooray!). And now, a new step for me appeared yesterday. I have a trainee for a month. And my task is to teach him how to work with ProcessWire! This make me really proud ! Have a nice day everyone and again, thanks to this community and this software! ?
    4 points
  3. Lucky you! You have the best job in the world! ? Q: What is a ProcessWire? A: Coding with a smile ?
    4 points
  4. This is when AdminActions (https://processwire.com/talk/topic/14921-admin-actions/) comes in handy: I will get around to providing this as a proof of concept action at some point, but this is what my import page looks like: This has been working great for me because I get to tweak the SQL queries (that I use to generate the CSV files that this action uses) and easily re-import. Just name the CSV files to match the template and this list is automatically generated: It also makes it easy to test with importing a few, many, all, or a selected one: I am going to use this for all my future site migrations.
    3 points
  5. You can change the module service url in your config.php file. $config->moduleServiceURL = 'http://modules.processwire.com/export-json/'; $config->moduleServiceKey = (__NAMESPACE__ ? 'pw300' : 'pw280'); Format of the complete url: {moduleServiceURL}/{moduleClassName}/?apikey={moduleServiceKey} Example: http://modules.processwire.com/export-json/MarkupCookieConsent/?apikey=pw300 If you provide this service (json format) for your module by your own you could hook in ProcessModule::execute if ($input->get->update) { $this->addHookBefore('ProcessModule::execute', function($e) { $moduleClassName = $this->wire('sanitizer')->name($this->wire('input')->get->update); if ($moduleClassName != 'MySuperPrivateModule') return; // change service url here $this->wire('config')->moduleServiceURL = 'http://example.com/export-json/'; }); } Another solution: Symlink your module if all sites using this module are hosted on the same server.
    3 points
  6. Congratulation @flydev !! You are an amazing contributor to this community and it shows in how you influence businesses decisions with your work and dedication and that's invaluable for all of us looking to get jobs using PW.
    3 points
  7. Yes I should take the time to write a showcase, I am sure that our use of ProcessWire will interest a lot of people!
    3 points
  8. $your_field->label = ''; //first need to set field label as empty string (important!) $your_field->skipLabel = true; //works only if the label is set to empty string
    2 points
  9. You can take a look at one of my blog site profiles, e.g. Editorial, to see a working example you can adapt to your site. It's built on PW and the blog module @pwired linked. The "widgets" are pages with a PW template (that doesn't prepend and append anything in the template's family settings) and PHP file generating the output for each widget a page living under /widgets To display widgets on a page, the blog-settings template for the page where the site's configuration is stored has a page reference field "blog_widgets" where one can assign and order the widgets to be shown. In site/templates/blog_sidebar.php the settings page is retrieved and a small code snippet like this renders all selected widgets: foreach($blogSettings->blog_widgets as $widget) { echo $widget->render(); }
    2 points
  10. We are here to exchange ideas, so please try to stay besserwisserisch as I understand that I needed to explain my approach a little better ?. My JSON data not only contained user login information but other stuff like avatar images, signatures various settings (from the origin) etc. My template is more a viewer for that data which allows to import or update contents on a per-user base. Of course I could also create that as a module, but for that one-time use going with a template was more straight forward for me. I prefer making a module for the reusable stuff.., That's what I meant that migrating the password (probably) does not work, unless you are able to decrypt the hash code stored in the database. I'd set some randomized password and integrate the LoginRegister module along with ForgetPassword so users are able to restore their accounts on their own. And, yes, I've omitted the closing brace in my snippets (thought it was too obvious). The row looks ok, but maybe your JSON includes some additional headers which need to be referenced first (the part before the first row of user data) like this: { "Type" : "UserData", "Users" : [ { "ID": .... Then your foreach would have to start on $UserData["Users"] and you could verify $UserData["Type"] before starting the import.
    2 points
  11. Welcome to the forum ? Create a file in site/template called admin.php with this code : <?php namespace ProcessWire; require($config->paths->adminTemplates . 'controller.php');
    2 points
  12. Hi, check @adrian's answer there : You can also make a small autoload module which check the user's roles then redirect him accordingly.
    2 points
  13. This is a lightweight alternative to other newsletter & newsletter-subscription modules. You can find the Module in the Modules directory and on Github It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin. This module fits your needs if you... ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk EDIT: Since 0.0.4, instructions and changelog can be found in the README only. You can find it here ? If you have questions or like to contribute, just post a reply or create an issue or pr on github, thanks!
    1 point
  14. I open this topic because in another one (http://processwire.com/talk/topic/1732-shop-for-processwire-apeisa/) there was a discussion going on that -in my point of view- went off-topic. Here's what it's all about: Say you want to create a module that needs some additional scripts/stylesheets what is the best way to accomplish that? Right now I only know three ways (which all have their weaknesses): First: Just edit the head.inc and include those scripts in the head-tag. OK, this is pretty easy but it has two drawbacks: - The scripts are now on every page (in the front-end) - You have to edit the head.inc* Second: Include <?php foreach($config->scripts->unique() as $file) echo "\n\t<script type='text/javascript' src='$file'></script>"; ?> in your head.inc and add the scripts from your module with $this->config->scripts->add($this->config->urls->PaymentExample . "script.js"); This seems pretty neat because the scripts will only be included where they are needed, but: - It is not very flexible. What about in-site scripts? - You have to edit the head.inc* Third: Use the hooking- mechanism of PW by adding $this->addHookAfter('Page::render', $this, 'addScripts'); to the init- function of your module. This is the addScripts function: public function addScripts($event) { $page = $event->object; // don't add this to the admin pages if($page->template == 'admin') return; //other mechanisms to ensure the script only loads when this module was called in the front-end $additionalHeadScripts = '[myScripts...]'; $event->return = str_replace("</head>", $additionalHeadScripts.'</head>', $event->return); } Of course this approach also has its drawbacks: - It is a bit difficult - It probably makes your PW installation run a bit slower because the addScripts- Methods gets called on every page request. *Why is it a bad thing to edit the head.inc to provide scripts/stylesheets for your module? I personally think if you want to distribute a module the admin that wants to integrate this module should just hit the install button and do some configurations and that's it. This is called usability and I believe in it. In my opinion it is not user/admin friendly if you have to pack a readme file to the module that says "but first you have to alter your template file to make that module work"... That said, if <?php foreach($config->scripts->unique() as $file) echo "\n\t<script type='text/javascript' src='$file'></script>"; ?> was already in the default template head.inc file I would not hesitate one second to use the second approach for my module. Because if an admin creates his/her own template and it is not based on the default template it's his/her fault... So, what do you think? Which is the best approach for you and why? Or do you have another approach? Maybe it would also be a good thing if there was something in the API that we could use for this need. A more standardized approach?
    1 point
  15. I have been using Processwire on a few personal sites and recently got a new project at work to redesign our corporate site using Processwire. I've been diving into the flexibility of PW and I love it especially with things like the Repeater Matrix in ProFields. I need to build out something pretty flexible for our content team and want to implement a robust system of reusable content. Essentially our content team wants to be able to build things like Priceboxes and various content chunks and reuse them throughout other pages on the site. I was thinking this would be a use case for Page Reference fields, but I'm unsure how to go about it as I've found the documentation a bit scare and I'm still getting used to the intricacies of PW. Is this a good case to use Page References? How would I go about setting that up and are there perhaps other strategies for reusable content I should consider. I'd like to keep things as visual as possible for the content team who are generally not very tech savvy. Thanks.
    1 point
  16. I am trying to figure out the best way to handle developing a module for multiple private ProcessWire sites. The key issue being: when I update the module, how can I elegantly get the changes in the sites that use it. It would be nice to not have to copy/ftp the files from site to site, or entangle them in git history (maybe as a sub module?) The ProcessWire modules directory has a nice upgrade module which can elegantly notify/click+upgrade publicly hosted repos. But this would be private code hosted on a private repo. I assume this would preclude it from being hosted there? Can someone point me to a solution for this, or perhaps brainstorm any possibilities.
    1 point
  17. Use a hidden inputfield: $field = $modules->get("InputfieldHidden");
    1 point
  18. Hi GFXmonkey, there are many option to do that. Here is very basic example. 1) Eg. outside of main pages tree, create hidden parent page, eg. "Addons" (or "Blocks", "Widgets", or...). 2) Inside "Addons" tree you create and store reusable content (pages) using various templates (eg. slider, text-image, call-to-action, downloads, etc...). 3) Now what you also need is page reference field (eg. name "widgets") on pages inside main tree - to select - pages from "Addons" tree. How to use this concept? Example: "Text-Image widget" 1) Inside "Addons", create new page using template "text-image", place some image and insert some text. 2) Go to desired page (where you have page reference field "widgets") and select newly created "text-image widget" (1) How to render it? Also many options, but simple can be: if(count($page->widgets)){ foreach($page->widgets as $widget){ // as example widgets templates are in folder "widgets" // also this part can be different, find tutorials about ProcessWire render() method... include('./widgets/' . $widget->template->name . '.php'); } } Regards.
    1 point
  19. It should be src="https://www.youtube-nocookie.com/embed/abc123?feature=oembed&rel=0" in order to work. It seems that TextformatterVideoEmbedOptions module can't add the options to your custom TextformatterVideoEmbed module. Install the original TextformatterVideoEmbed module and you'll see that the "rel" will be added properly.
    1 point
  20. Well, either you strip those headers manually (which you did) or enumerate over all containers, search for the user table and continue to process that one (code only to get an idea, probably contains some typos): $AllData = json_decode($http->get('localhost:8888/playwood/pw_users.json'), true); foreach($AllData as $container) { if(($container['type'] == 'table') && ($container['name'] == 'name_users')) { $UserData = $container['data']; foreach($UserData as $v) { : } break; } } If the generated users are named from current timestamp then I suppose that $UserPwName is not set correctly. Did you check that $UserLoginName is read correctly from your data (maybe adding d($UserLoginName); and d($UserPwName); helps).
    1 point
  21. Your code looks good... i think the problem is your json file, i tested it with this json Data: [ {"ID":"1","user_login":"myname","user_pass":"$P$BKVS\/30bpzejiORa9nGupsAur7g0P\/","user_nicename":"mynicename","user_email":"email@email.it","user_url":"","user_registered":"2016-07-28 16:13:39","user_activation_key":"","user_status":"0","display_name":"myname"}, {"ID":"2","user_login":"myname2","user_pass":"$P$BKVS\/30bpzejiORa9nGupsAur7g0P\/","user_nicename":"mynicename","user_email":"email@email.it","user_url":"","user_registered":"2016-07-28 16:13:39","user_activation_key":"","user_status":"0","display_name":"myname"} ] You need the Start "[" and End "]" (and no comma after the last entry! ? )
    1 point
  22. Thanks Bernhard for stepping in on this. I wasn´t sure how to reply on this situation.
    1 point
  23. But since this is your second post and anyone could ask this question . . . . . . . . . . . . . Best way is to contact the hosting company of that website and ask them for help.
    1 point
  24. In this case I'd create a processmodule ? ? Don't want to be besserwisserisch, really just saying it's very easy to create them and you get a lot of flexibility and features with very little effort. For example a little import site could be as simple as this (available at yourmodulepath/import in the admin): public function executeImport() { if(input()->post->submit) { // do the import $this->import(); } $form = modules('InputfieldForm'); $form->add([ 'type' => 'text', 'name' => 'myinputfieldname' ]); $form->add([ 'type' => 'submit', 'name' => 'submit', 'value' => 'import my data!', ]); return $form->render(); } private function import() { // import logic }
    1 point
  25. Sure, using the debugger for such one-shot solutions may be faster to go. In my case the template contains much more functionality, since it generates a regular visible page. There I could pick the users to import or update information after changing fields in the user template etc.
    1 point
  26. Yep, as @Autofahrn said it's easy to do that via the API and a foreach. But I would suggest using Tracy Console instead of a template. Just create your code, debug it instantly using d() and CTRL/ALT+Enter and then finally do the import when everything works as expected. You can use the Password class to generate new passwords: $pw = new Password(); $pw = $pw->randomPass([ 'minLength' => 10, 'maxLength' => 10, 'maxSymbols' => -1, 'minUpper' => 0, 'maxUpper' => -1, ]); See https://github.com/processwire/processwire/blob/master/wire/core/Password.php#L419
    1 point
  27. If you can export the user as JSON, it should be simple enough to write a small importer in PHP. When I did similar, I created a template with a simple file field holding the JSON containing the user database. The associated template php starts like this: <?php namespace ProcessWire; if(isset($page->json_file)) $UserData = json_decode(file_get_contents($page->json_file->path . $page->json_file->first()->name), true); else $UserData = [ ]; // ensure always set, yet empty. depending on your JSON structure you'll iterate through your users somewhat like this: foreach($UserData as $v) { // Fetch whatever fields should be imported $UserLoginName = $v["LoginName"]; $UserRealName = $v["RealName"]; $UserMail = $v["EMail"]; In my implementation I'm building a pagename from the original name and check if the user actually exists: $UserPwName = $sanitizer->pageName($UserLoginName, true); $usr = $users->get("name={$UserPwName}"); Of course you only want to add a user which does not exist yet (you may do other things like update for existing users): if($usr->id == 0) // User does not exist { $usr = $users->add($UserPwName); // Create user if($usr->id) // Success? { $usr->of(false); // Prepare for update $usr->email = $UserMail; $usr->addRole('imported-user'); // add some special role here // add more fields depending on your use case // $usr->user_name = $UserRealName; $usr->save(); } else { // may $log->error("ERROR creating user {$UserRealName}"); } } Shouldn't be too difficult to adapt for other scenarios. Take care of the passwords, which likely can't be migrated that way!
    1 point
  28. I had this on an full webspace....so site is running...but there is no more place for the session on the webserver so i get the same message. After stopping an uncontrolled backupscript and delete a lot of waste all works again...
    1 point
  29. I'd like a lot to have a teacher ?, learning alone sometimes it is very stressful!! Anyway, I take this opportunity to say really thank all of you members of the forum that you helped me so much! specially you @flydev that help me a lot with the login/registration module!! surely you will be a good teacher!
    1 point
  30. It's very, very bad practice to use sleep() in a server side script, that is why documentation on working around the pecularities of PHP's buffering (and thread execution) is so sparse. sleep() blocks the whole thread it is called in, and under heavier load, it makes servers utterly unresponsive. There also fine differences in buffering behaviour depending on how PHP is executed (mod_php, FastCGI, classic CGI...) The usual solution to situations where you are tempted to call sleep() is to poll until the condition you need to wait for has been reached, either using classic reloads for the current page or with AJAX. Nowadays, websockets are also used to split off parts of the work to different processes and notify the "owning" session of changes of state in the backend.
    1 point
  31. Updated to version 0.0.4 - checkout the changelog . The Github user ml-s fixed a major issue, where you could not use a Mailchimp core function, the ADDRESS mergefield.
    1 point
  32. @tires The pull request is here https://github.com/ryancramerdesign/TextformatterVideoEmbed/pull/12
    1 point
  33. sure, so the (currently named) SimpleThemeEngine is basically a front end api, which is now in module form, but was previously a loose collection of functions that were used procedurally. I would probably recommend to use Spex since it released and proven to work; My module is probably too specific for general release at the moment... It uses WireData class for storage and provides methods for: Adding, manipulating assets (css/js) outputting assets (css/js) Getting and setting theme variables/settings (used for layouts, like show/hide page header, etc) injecting inline js code in head/foot simple web fonts management, loading etc injecting markup into parts of the page (sort of layout hooks) problem with releasing module is that it depends currently on ProCache being installed (future version would have setting to select the caching/min engine, e.g. AIOM or PC)... below is an example of the code that would be used in the head.... // $ste = $modules->get('SimpleThemeEngine'); echo $ste->headAssets(); echo $ste->getJsConfig(); echo $ste->gFontLoader('Open+Sans:300,400italic,400,600,700|Montserrat:700'); echo $ste->getInjects('header');
    1 point
  34. Because of this, I would be interested in a team effort to build some common grounds based on the new Markup Regions and UIkit 3. If there were enough of us to take this path, we should be able to build some unofficial "PW theme for developers". I agree
    1 point
  35. Hook after ProcessLogin::afterLogin and there, if $this->user->roles has a match, do a $this->session->redirect().
    1 point
  36. Put this in your site/ready.php file: $this->addHookAfter('Session::loginSuccess', null, function($event) { if($this->wire('user')->hasRole("target-role")) $this->wire('session')->redirect("other-url"); });
    1 point
  37. This works pretty straight forward echo $image->title($languages->get('en')); // $image->title($languages->get($input->get('lang'));
    1 point
  38. You're right, somehow there was a missing equal sign Thanks for the feedback, please pull the latest version from Github!
    1 point
  39. @justb3a Thanks for the great modules. Just what I needed for my last project. One thing I stumbled upon: I cannot delete text that has been inserted before. Since the existence of the input is a condition for outputting a caption or not it is necessary to have an empty field again. Doesn't matter if placed inside a repeater or not. Can you repoduce that, or do I miss something. Thanks in advance!
    1 point
×
×
  • Create New...