Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/16/2017 in all areas

  1. The company which I'm working for develops apps, too. And for one of them we need a little notification system. Just a little endpoint which returns json. The app saves all notes which have been sent to the user. To be able to identify which message has already been shown, we need a global identifier. The workflow is as follows: Login PW Admin add a new page, the "id" field will be populated with a GUID fill in all other fields which should be sent an endpoint returns json, for example something like the following [ { "id":"936DA01F-9ABD-4D9D-80C7-02AF85C822A8", "url":"https:\/\/domain.com\/endpoint\/notice1\/", .. }, { "id":"A36DA01F-9ABD-4D9D-80C7-02AF85C822A8", "url":"https:\/\/domain.com\/endpoint\/notice2\/", .. } ] as you can see, for each note there's a "detail" page which will return the actual message if someone opens the app, it checks whether there are new notes and displays them
    5 points
  2. First, some background to lit a light. There are some functions in PHP that may produce unexpected results in special situations. This functions are used by PW core files and in user contributed modules. Some users may have problems with file upload (pdf, zip, image, whatever) if filename has non-ascii character at the first place. For example, if user upload a file named "år.jpg" (year in Swedish language), it is expected that PW would transliterate (transform) the filename to "ar.jpg", but because of the bug in basename() PHP function, the filename would become just "r.jpg". Nevertheless the file would upload successfully. But if the filename is "привет.jpg" (Hi in Russian language) the upload would fail. There are two ways how to handle this: Write and use custom functions instead of builtin functions Let end user fix that with proper locale Option 1. is used in some CMS/CMF (like Drupal), PW (Ryan) opted for option 2. After successful login PW perform a test and warning is issued in case of test failure. It is now your responsibility to set proper system locale. The locale is a model and definition of a native-language environment. A locale defines its code sets, date and time formatting conventions, string conversions, monetary conventions, decimal formatting conventions, and collation (sort) order. Those "problematic" builtin PHP functions are locale aware, that means they work as expected, if locale is configured appropriately. Locale can be set by the underlying operating system or in PHP. Because on shared hosting you don't usually have root access to the OS, the only option to set the locale is by using the builtin setlocale() PHP function. But, before you can use/set the locale, it must first be installed on the OS. On most unix systems at least some basic locales are already there, they are just not used. To check what locale are you currently using and what locales are available for you to use, create the file testlocale.php at the root of your website with the following content: <?php echo "<pre>Current locale:\n" var_dump(setlocale(LC_ALL, '0')); echo "\n\nAvailable locales:\n"; echo exec('locale -a'); Then point your browser to http://yourwebsite/testlocale.php If your current locale is "C" (and you are on unix), then you will probably get warning after login to the PW admin. What you want to do is change the locale to something that has "UTF-8" or "utf8" in the name of the available locales. In your case you would be looking for something like "sv_SE.UTF-8" or "sv_SE.utf8". Now, there is a chance that Swedish locale is not installed. You can ask your hosting provider to install it for you or use some other UTF-8 locale. On most unix systems I have seen, at least "en_US.UTF-8" or "en_US.utf8" is installed. If even that English locale is not available, then look for "C.UTF-8" or "C.utf8". And this is what you have to use as parameter in the setlocale() call: setlocale(LC_ALL, "sv_SE.utf8"); You could actually "stack up" multiple locales and one will eventually work: setlocale(LC_ALL, "sv_SE.utf8", "sv_SE.UTF-8", "en_US.UTF-8", "en_US.utf8", "C.UTF-8", "C.utf8"); Now, regarding where to put that setlocale() call. If you are not using PW multi language capabilities (you don't have Languge Support module installed), then you place setlocale to /site/config.php. That's it. If Language Support module is installed (PW checks for that), you have two options: Translate the string "C" in LanguageSupport.module for each installed language Put setlocale() call in /site/init.php My preferred method is option 1 and this is what PW (Ryan) recommends. See https://processwire.com/api/multi-language-support/code-i18n/ for more info on translating files. Option 1 allows you to set different locale for each of the installed language, while option 2 allows setting of one locale for all languages. PW will also provide links for the files that needs to be translated in the warning message. Ryan just pushed an update that makes it use the locale setting on the frontend when using LanguageSupportPageNames module (until now just language was changed, but not locale). Also setLocale() and getLocale() methods are added to the $languages API var.
    4 points
  3. v133 contains a new CKE plugin Code Snippet which lets you insert rich code snippets with syntax highlighting into the editor. The plugin uses highlight.js. On the frontend you'll need to include highlight.js assets and initialize (see more at higlightjs.org): To customize the languages available for selection and the theme, add this to /site/templates/admin/cke.js file (this is the auto-loaded configuration file for CKEditor, you can modify it in the Asset Paths section in AOS): CKEDITOR.editorConfig = function (config) { config.codeSnippet_theme = 'foundation'; config.codeSnippet_languages = { apache: 'Apache', css: 'CSS', html: 'HTML', ini: 'INI ', javascript: 'JavaScript', scss: 'SCSS', php: 'PHP', sql: 'SQL', }; };
    2 points
  4. Hi @MilenKo - thanks for the XML file - it was very helpful. I have committed a new version of Migrator to Github that fixes the duplicate comments issue and also now properly sets the approved status of comments. Note that I didn't test your complete file (because it would take quite a long time I expect). I cut it down to 5 posts, but with those everything is now working as expected. I didn't see the issue with the homepage being renamed, but maybe there is one post in there that is doing something strange. Could you please test with a limited set to make sure everything is working at your end. And then try with all and let me know about the homepage issue. If you could narrow it down to a particular post then I should be able to fix. It's probably a good idea to start with a completely fresh PW install (after all your previous attempts, something might be messed up by now) - you can even let Migrator install the comments module and set up the field etc. Thanks, Adrian
    2 points
  5. It should be possible to do this by specifying a base: <base href="<?= $config->urls->templates ?>myAppDirectory" /> in the header of the page. That means that relative link behavior changes as any url that doesn't start with a slash will be searched inside myAppDirectory.
    2 points
  6. Hi all, Just in front of the Easterweekend, my first contribution to the modules section of ProcessWire. I created a module to send Tweets when selected at the page editor. From version 0.8.3 up the module is only to use in v3.x. When using ProcessWire v2.x you should use version 0.8.2. In short this module offers an option to publish a page to Twitter when the date for publishing is past/scheduled. After filling out the Twitter credentials, select your preferable template(s) which should have the option added to Tweet the pages using it. Additional select the field to use as publicationdate to check if the Tweet should be send now or later, a field which contains the page title. Optional you can fill out the name of the website which will be added after the title (in case space is available). Optional you can select the field where the page image(s) are placed (only one will be tweeted). Optional you can fill out Bit.ly credentials for shortening URLs. Includes instructions to set a cron (template or LazyCron), returns log in assets folder. Uses (included) TwitterOAuth PHP library written by abraham. http://modules.processwire.com/modules/publish-to-twitter/ https://github.com/FerdiAgrio/PublishToTwitter Enjoy!
    1 point
  7. FacebookEvents ProcessWire module to get Facebook Page Events using the Graph API. Create an app on Facebook developers website You have to create an app to get appId and appSecret. Those keys are required. Go to Facebook Developers and add a new app. Congrats! Now you can copy your Facebook appId and appSecret. Get your Facebook page ID You can either enter your facebook page ID or the facebook page name. If you enter the Facebook page name, this module will get the page ID for you! Call Module $events = $modules->get('FacebookEvents')->getEvents(); Output Events {% for event in events|reverse %} {% if event.start_time|date('U') > date().timestamp %} <div> {% set dts = modules.get('FacebookEvents').getDates(event) %} <a href="https://www.facebook.com/events/{{event.id}}/" title="Facebook">{{dts.dates}}:</a> {{event.name}} <em>{{dts.times}}</em> </div> {% endif %} {% endfor %
    1 point
  8. GUID Generator Generate a globally unique identifier (GUID) for Inputfield Text. Usage For each instance of a text field the field settings will be extended. Navigate to Admin > Setup > Fields and edit the desired field. Click on the Input Tab and click on the "Generate GUID" area. It extends downwards and reveals a form to enable automatic GUID generation. After having enabled GUID generation for a text field, edit a page which has a template containing this field. You'll see the field filled with a GUID.
    1 point
  9. GithubConnect ProcessWire module to connect a Github OAuth application. Register a new OAuth application Fill in module settings Click the Authorize! link to generate code and access token There are some predefined endpoints to fetch informations about an user or a repository, get a list of repositories belonging to an organization, fetch content of readme or certain file.. I used it to choose a repository from a list and import the content (e.g. readme, description) to the corresponding fields. Visit the Github Repository to get a full overview.
    1 point
  10. Huh, it is true - ideas we could have plenty, but there are only 24 hours in 1 day and they are never enough Thank you again for being so helpful...
    1 point
  11. It would be possible (and probably a good idea) to add this functionality to Migrator, but it's beyond what I have time for at the moment I'm afraid.
    1 point
  12. Oh yes, I should mention that I did my testing with 3.0.55, but it should still work in 2.x Thanks for helping to narrow down what might be causing that homepage change. I think it will be a matter of doing chunks of posts (maybe 20 at a time, or something like that) and then narrowing down from there. There must be something weird
    1 point
  13. @adrian Thank you very much for the update and I am glad I helped a bit in the process. I will try to import a few posts first and see how it goes after which I will try to import the whole database. If the posts are imported properly but only one changes the homepage - I can totally live with this, but I understand your point of having that fixed so that it does not affect somebody else using the module. To import the WP to PW I am definitely using the latest PW 3.X with a blank profile. After I do that, I will just need to import my existing profile I have almost finished. But let's do this step by step and at the end we will have a nice and smooth approach. Will let you know as soon as finish both tests.
    1 point
  14. Glad that worked for you @jmartsch On another note, the new Selector Queries section in the DebugMode panel now includes a "Time" column so you can see how long each of your selectors is taking. Note that #7 is an intentionally relatively slow query to make a point for this screenshot: Keep in mind that caching may get involved here once you reload a page. Clearing the session (eg logging out and in again) will show you the speed on first load for a user. Also, just added a "Logout" icon/button to the PW Info panel - nice shortcut if you want to logout from the front-end of your site.
    1 point
  15. @dweeda here is all the info you need https://processwire.com/api/include/ @abdus the info above is the official way to do this.
    1 point
  16. oh, thanks - yeah, didn't get around to doing the 'collapsable' rows on that page - thanks for the heads up!
    1 point
  17. Thanks for the suggestions. I'll put this on the back burner, really need to stick at javascript for awhile first, although I'm finding it pretty tedious. Don't know what it is with me and javascript, been trying to learn it off and on since about 2004 to no avail, always quit and go mess about with CSS and design instead. I guess I don't have anything to actually use it for right now other than adding classes here and there. Then I was thinking last week about an ajax search which users could find pages on my site without navigating around by typing in questions, like "How much..." would pop up my pricing page etc, That would need javascript! And I'd have a goal. Then I saw this: Copying and pasting wont get me anywhere, but this will really address the 'where to start' problem us wannabe developers have. Reading JS books and watching videos is all well and good but this gives me something to learn as I go along, makes all the difference to me. Went a bit off topic there, but hey.
    1 point
  18. Another nice module for PW, thanks @ryan ! Tried to use this module with PW 3.0.55 , no problem, it's compatible. Also did a small mod which enables basic support for FieldtypeMapMarker (lat and lng only). Will share my code if it's interesting for someone.
    1 point
  19. I mostly try to use FormBuilder which does all the work However, if I need special forms in terms of styling or functionality, I'm using the ProcessWire form API to render and validate/process the input. You also get free CSRF protection. Here's an example how roughly works (written in browser, not copy paste ready): // Controller contact.php // ------------------------ $form = $modules->get('InputfieldForm'); $select = $modules->get('InputfieldSelect'); $select->required = 1; $select->setOptions(['blub', 'blub2']); $form->append($select); $csrf = $session->CSRF->renderInput(); $view->set('inputs', ['select' => $select', 'csrf' => $csrf]); // Validate and process the input if submitted if ($isSubmitted) { $form->processInput($input->post); // Handle errors and success } // View contact.twig // ------------------------------ <form action="{{ page.url}} " method="POST"> <label>Select</label> {{ form.select.render() }} {{ csrf }} <button type="submit">Submit me</button> </form> Cheers
    1 point
  20. You were right, it was a permission problem. Logged in as admin and the bar showed up. Sorry for bothering you. Could have thought of this myself.
    1 point
  21. Is there are Page templates (/processwire/setup/template/) with a Process called Template in your back-end?
    1 point
  22. 1. No. 2. Why would you install language support if you don't need it? 3. sv_SE.UTF-8 4. echo exec ('locale -a'); Have to go now, will post more information/clarification of my brief answers later, stay tuned.
    1 point
  23. current version has properly formatted currency fields (atm only euro) and supports colorbars and column sums (also from selected rows) had to remove this video, sorry
    1 point
  24. Small update that: 1) lets you add: protected $noBackup = true; to your action class to prevent backups (either automatic or from showing the option to backup). This is handy if your action doesn't do any DB writing in which case a backup isn't relevant. 2) lets you populate: $this->output = 'Content for output'; to your executeAction() method. Whatever content is in this will be returned before $this->successMessage and won't be formatted with the green background. This is useful if your action queries and displays info. Hope you guys find these useful. PS - still waiting on the first PR for a user contributed action
    1 point
  25. That's strange. Can you confirm your 'admin' user is a 'Superuser'? If they are, then you should have access to everything. You can use the API to change all sorts of things, including permissions.
    1 point
  26. I too had used wordpress a long long time ago, and even wrote a few plugins for the 2.x versions since there was nothing out of the box available for my needs. I dumped it because that square peg was being force-fit into the round "one size fits all" hole with each passing version at the cost of security. And more and more plugins were coming on board that didn't work, had no support, wanted payments, and embedded hidden ads without your knowledge. I'm glad I came across ProcessWire because I can solve my needs any way I see fit; that proverbial skinned cat. As an example, I wrote my own front-end user management system simply because ProcessWire makes it easy to do so, and it does exactly what I want, and ProcessWire doesn't impose restrictions. You don't have to write your own, however, as there are quite a few user management modules/code snippets available to you in this forum, but you are certainly welcome to do so. This community would welcome your contribution, and gladly assist you with its development. One other option is to hire someone to develop your module(s) to your specifications (See the Jobs forum).
    1 point
  27. @MilenKo - sure, send it through - I'll try to test later today.
    1 point
  28. If I follow the link there are no issues...?! Second welcome email? -> just hook into the process and send one. Use PW API / hooks Add a role -> write a PW hook. Default role? See documentation example... -> https://bitbucket.org/pwFoo/frontenduser/wiki/Register extensions and plugins Custom fields...? See example https://bitbucket.org/pwFoo/frontenduser/wiki/Code snippets / Examples Style a form api field? -> Search forum and PW documentation about PW native form api and inputfields. Get form object: $fu->form. Overwrite the register form? Ok, just do it... https://bitbucket.org/pwFoo/frontenduser/src/0070dc3106945198ac438bab3ab742b1784080e9/FrontendUser/FrontendUser.module?at=master&fileviewer=file-view-default#FrontendUser.module-78 See first function param $fields validation email template (default): https://bitbucket.org/pwFoo/frontenduser/src/0070dc3106945198ac438bab3ab742b1784080e9/FrontendUser/templates/validationEmail.php?at=master&fileviewer=file-view-default $file = wire('fu')->getFile('validationEmail.php', 'templates'); getFile() function... https://bitbucket.org/pwFoo/frontenduser/src/0070dc3106945198ac438bab3ab742b1784080e9/FrontendUser/FrontendUser.module?at=master&fileviewer=file-view-default#FrontendUser.module-199 /** * Load custom or default styles / scripts * @param string $file Filename to load * @param string $type File type styles or scripts */ public function getFile($file, $fileType, $type = 'paths') { $custom = $this . '/' . $file; if (file_exists($this->config->paths->templates . $custom)) { $file = $this->config->$type->templates . $custom; } else { $file = "{$this->config->$type->$this}{$fileType}/$file"; } return $file; } Have I pointed to the module documentation before... ?! https://bitbucket.org/pwFoo/frontenduser/wiki/Documentation#markdown-header-styles-scripts-templates Maybe, I haven't tested it. It seems there was a change inside the password inputfield which needs additional css / js to work... The FrontendUser module is just based on form api, inputfields, hooks. PW native features. So if you know PW you know how to extend the module. Since I'm currently busy in my job, I'm missing the time to rework the module, but it should be flexible enough for most of the needed extensions / plugins. If there is a bug or problem a pull request is welcome
    1 point
  29. @MilenKo - I don't know why this is proving so problematic for you. I haven't ever imported a WP blog into the PW homepage - always into /blog/, but it has always worked perfectly and I have never had to create any fields ahead of time, including the comment fields. The pending status is a known issue. I had been waiting on the response to this: https://github.com/ryancramerdesign/ProcessWire/issues/1034, which ended up here: https://github.com/processwire/processwire-issues/issues/88 - it looks like it can be solved now.
    1 point
  30. Location of setlocale() in /site/config.php is not important. What locales are installed on the system? What locale are you trying to set? PW version you are using? Please upgrade to latest dev (3.0.55). Is Language Support module installed? init.php is located at /site/ folder, create it if needed.
    1 point
  31. @DL7 I haven't used this module, but I see that it's not autoload in templates so try this before you save the page via the API: $modules->get("PublishToTwitter");
    1 point
  32. Thanks Harmen and Macrura for trying to help. It was a permission problem . Forgot to check and change permissions after the extraction... I' m too old to learn from my repeated mistakes...
    1 point
  33. I don't think you need to rename anything, although I haven't used phpDocumentor myself. I use apigen (as seen here). You can tell it in a configuration file what file extensions to parse. I see phpDocumentor has a similar feature as explained in its documentation here (see extensions). Meaning, something like below should work. <parser> <target>output</target> <encoding>utf8</encoding> <markers> <item>TODO</item> <item>FIXME</item> </markers> <extensions> <extension>php</extension> <extension>module</extension> </extensions> </parser>
    1 point
  34. You can use yourmodule.module.php Cheers
    1 point
  35. @MilenKo - if you fix that error and posts are still not being imported fully, PM me your XML file (if you can) and I'll take a look - it should work fine.
    1 point
  36. @Robin S is right, Git will not solve your main issue. You might want to consider using online solutions, like: https://codeanywhere.com/pricing To tell the truth, I do not have any experience with such services, so I do not know how much they can help regarding your database connections. I always work with two databases, local and live.
    1 point
  37. This is really strange. What other Modules do you have installed (asking this question feels a little "WordPress" )?
    1 point
  38. Learning Git has got to be a good thing (I need to learn more about it myself), but in terms of solving the "two computers for local development" issue in the quickest and simplest way I would have thought this would be the thing to look at: I think you want a single version of the files and DB on the laptop (in case you need to work away from home some time) and then access those on the desktop machine via a local network. Just leave the laptop on when you want to work from the desktop. Or another idea: just carry the laptop downstairs and work exclusively on that machine (I have a large external monitor and external keyboard I plug my laptop into when working at my desk).
    1 point
  39. @SamC, I usually do what @BitPoet suggests and create custom login and profile edit forms for the front-end if the user only needs to edit their profile (or some other single page). But there are a few modules and snippets around that take the approach of creating a custom dashboard in the PW admin for users with non-superuser roles and redirecting them to that when they log in rather than the page tree. Here are a couple of links, and just search for "dashboard" to find more: http://modules.processwire.com/modules/process-dashboard/
    1 point
  40. @ottogal Independently of the opportunity of this suggestion, It doesn't sound at all like @theoretic is joking, you can see that there is some thought and work in that logo either you like it or not. There's too much trolling going around the world these days, let's try to keep this little corner of ours a nice and constructive place. I'm not trying to bash you down, but please try to be a bit more explicit about what you didn't like when criticizing someone else's post. @theoretic you might want to go through this thread to get a feeling of what was already discussed about this subject
    1 point
  41. If you just want a notification that a page is currently being edited by another user (like the default behaviour of Page Edit Soft Lock) then the optional core System Notifications module also has that feature. But if you want a "hard lock" option then I think Page Edit Soft Lock is the only option currently.
    1 point
  42. If you link to GitHub, please use the commit-id (instead of branch-names). Otherwise, future editions could make those links pointless. … … Example usage: Blog and Matrix modules. Protip: To get the SHAified url on GitHub, go to any file you want to link to (e.g. https://github.com/kongondo/Blog/blob/master/ProcessBlog.module) and press Y (without anything, just y) on your keyboard.
    1 point
  43. It's not only the same error in the log, but you're also doing the same thing wrong. You can't use $pages in functions because of variable scope. ProcessWire makes these object automatically available for the scope of the templatefiles, but inside a function is a new scope, so you need to either redefine the variable itself or use a function to get the object. // Template scope $id = 15; // simple variable, defined by you $pages = $pages; // the pages object, defined automatically by processwire function something(){ // this is now a new variable scope // neither $pages nor $id are available here. // the api variables are not a special global variable $pages = wire('pages'); $pages->find(""); // OR just wire('pages')->find(""); } It's the same reason, why you can't use $pages in modules. $page/$pages and the other variables are just convenient to use in templates. Everywhere else you need to call them differently.
    1 point
×
×
  • Create New...