Jump to content

Raymond Geerts

Members
  • Posts

    365
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by Raymond Geerts

  1. As requested an example on how to output the star rating on the front-end. This one is based on Font Awesome, but you can adept this to any font or even plain images if you prefer. <?php /** * Small example output for FieldtypeStarRating on the front-end * */ ?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title><?php echo $page->title; ?></title> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"> <style> .star { color: #d9d9d9; } .star.selected { color: #FFAE00; } </style> </head> <body> <h1><?php echo $page->title; ?></h1> <span> <?php $star_count = $fields->star_rating_field->star_count; for ($i = 1; $i <= $star_count; $i++) { if ($i <= $page->star_rating_field) { echo "<span class='fa fa-star star selected'></span>"; } else { echo "<span class='fa fa-star star'></span>"; } } ?> </span> <?php if($page->editable()) echo "<p><a href='$page->editURL'>Edit</a></p>"; ?> </body> </html>
  2. I'm using FormBuilder for mostly all forms its a small investment (since it is a commercial module). But it saved many hours of coding and debugging. And as additional benefit it supports Ryan (the creator of ProcessWire) in a little way.
  3. I'm not sure if i understand your question entirely, it seems too obvious to me, so it might be i miss understood. Anyway, you can connect to as many subdomains as you like. There are no restrictions on linking from pages. On the other hand, you might need to consult your hosting party, if they support subdomains, since this is something that differs from one provider to the other. Maybe you can explain in detail what the goal is for connecting to a subdomain, so that people might give a more specific answer.
  4. On selector level you can select the pages where the image field is not empty asfollow. $pages_with_images = $pages->select("your_image_field!='', limit=25");
  5. Haven't tested it (wrote it in the browser). But something alike should do the job. Maybe add some extra sanitizing on the old and new pass too. Inside a template: if (!$user->isLoggedin()) throw new Wire404Exception(); if (!$sanitizer->name($input->post->submit)) throw new Wire404Exception(); $username = $user->name; $old_pass = $input->post->old_pass; $new_pass = $input->post->new_pass; if ($username === 'guest') throw new Wire404Exception(); if (!empty($old_pass) && !empty($new_pass)) { $u = $users->get("name=$username"); if ($u->id) { try { $u = $session->login($username, $old_pass); if ($u->id) { $u->setOutputFormatting(false); $u->pass = $new_pass; $u->save(); $u->setOutputFormatting(true); $u = $session->login($username, $new_pass); } } catch (WireException $e) { // show some error messages: // $e->getMessage(); } } } Inside a method: if (!$this->user->isLoggedin()) return; if (!$this->sanitizer->name($this->input->post->submit)) return; $username = $this->user->name; $old_pass = $this->input->post->old_pass; $new_pass = $this->input->post->new_pass; if ($username === 'guest') return; if (!empty($old_pass) && !empty($new_pass)) { $u = $this->users->get("name=$username"); if ($u->id) { try { $u = $this->session->login($username, $old_pass); if ($u->id) { $u->setOutputFormatting(false); $u->pass = $new_pass; $u->save(); $u->setOutputFormatting(true); $u = $this->session->login($username, $new_pass); } } catch (WireException $e) { // show some error messages: // $e->getMessage(); } } }
  6. I just added it to the module directory. Also did a tiny modification in one of the selectors in the javascript file.
  7. FieldtypeStarRating Module for ProcessWire - Field that stores an integer by using a star rating interface. Current version: 1.0.0 Module page: http://modules.processwire.com/modules/fieldtype-star-rating/ Github: https://github.com/Rayden/FieldtypeStarRating To install Copy to /site/modules/ and go to Admin > Modules > Check for new modules. Tested on ProcessWire 2.6.2 dev Usage back-end Create a new field with the fieldtype Star Rating. Set the amount of stars you want to show, by default it is set to 5 stars. Assign the field to any template. Now you can set the field value by selecting any of the 5 stars. The number saved to the database equals the number of stars that are highlighted. Hovering the stars will show a reset icon, which will reset the value to 0 by clicking on it.
  8. Mainly its has pages which contain a newsletter, these are grouped by site (there are a couple of sites that have their own newsletter) All newsletters have child pages which resemble the items in the newsletter. These vary from article, image, banner, agenda (feed), rss (feed) and twitter (feed), and such items. Another part of the tool is sort of a scraper tool, it fetches agenda, rss and twitter feeds and stores the content as pages in the database so they can easely be fetched from and used in a newsletter item. There is somesort of cleaning calls in the scraper page (which is called from a cron task). This removes all scraped pages that are older than a given date in the past.
  9. I was wondering what the best (fastest/lesses computing power) aproach in using PW API variables inside the $cache function call? (not actual code) Example 1 echo $cache->get("example-1", function($user,$page,$pages) {} Example 2 echo $cache->get("example-2", function() use($user,$page,$pages) {} Example 3 echo $cache->get("example-3", function() { $user = wire('user'); $page = wire('page'); $pages = wire('pages'); }
  10. @pwired Surpricingly the database aint that big, only 6.3 MB.
  11. CPU GenuineIntel, Intel® Xeon®CPU L5506 @ 2.13GHz OS CentOS Linux 7.1.1503 (Core) Memory 16GB Disk 120GB SSD RIAD1 Its running Parallels Plesk v12.0.18_build1200140811.16 os_CentOS 7 with ngix caching turned on
  12. Earlier this week i noticed one of our sites (tools) had the following URL while working in the manager /processwire/page/edit/?id=1257390 Then i realized there where already more then 1.2 million pages, and processwire still running smoothly like a charm. I just wanted to share it here, and that i'm realy happy with ProcessWire. Thanks go to Ryan and all contributers for creating and maintaining this wonderfull piece of software!
  13. I recently had a 500 Internal Server Error after moving a site. The cause in that particular case was that the database was not accessable due to wrong user credentials. The site was migrated from one PLESK host to another PLESK host, and it seemed that the database was correctly migrated but the password was set to something random. Not sure if thats the case with your website. But its probably worth mentioning here. ps. The error log file can reveal a lot of information about what can be wrong, have you looked at the log file yet?
  14. Many valid solutions above. Here is another method: Make the site only accessable when logged in to the manager if (!$user->isLoggedin()) die(); Put it somewhere in /site/templates/_init.php or /site/config.php
  15. @Sevarf2 The notice about the undefined index is fixed now in FieldtypePageWithDate v1.0.3 https://github.com/Rayden/FieldtypePageWithDate
  16. I will dive in tomorow, i think array_shift might solve it. At the moment i dont have a working example throwing the notice. Any chance you can send me an export of the files and database, so that i can install it here localy. Makes debuging a lot easier.
  17. I made a patch on GitHub. Could you take a look and let me know if it fixed the problem? https://github.com/Rayden/FieldtypePageWithDate/tree/Sevarf2-patch Only FieldtypePageWithDate.module has been modified.
  18. I dont see where you set $user->assigned in your code. You could try the following, hoping that it will solve your problem. (note the move of $page->of(false); ) if ($input->post->addfriend && $user->isLoggedin()) { $user->assigned = date("Y-m-d H:i:s"); $page->friends_waiting->add($user); $page->of(false); $page->save(); }
  19. Solved, the parent template "EDIT PAGES" for the current users role, needed to be ticked. Now it works fine, sorting pages from a custom dashboard within a MarkupAdminDataTable.
  20. Ok it seems i have set up everything now. The table (specificly all children of tbody) are sortable now with $('.blocksTable > tbody').sortable() In sortable() i have set some options like axis:"y" and beforeStop on beforeStop i gather the needed ids to pass as data, for example: 'TOKEN788378384X1421678958':'fXGyHPxU2xSBIFpuDI08ORL1Z1CTC0U5', 'id':1015, 'parent_id':1017, 'sort':'1015,1013,1014' Where the TOKEN is grabbed from the hidden input field with class _post_token, 'id' is the id from the page that was 'moved', 'parent_id' is the id of the parent page, 'sort' are the ids of the pages in the new order. These are posted with ajax to /processwire/page/sort/ The problem is i get the following message return, indicating the page is not saved because there are no changes. {"error":true,"message":"You do not have permission to sort pages using this parent - \/partners\/partnername\/blocks\/"} The strange thing is the current user has move and sort permissions, so i'm not sure what i'm missing here. Does anybody have a clue?
  21. Thanks Martijn, will take a look at jquery sortable, looks like its easy to setup. Will have to find out how to add some data attributes to a table row with the MarkupAdminDataTable, or else i might be able to do it with hidden form fields.
  22. I'm building a dashboard, based on the dashboard from Kongondo's Blog. In there i have Articles and Widgets. Articles are sorted by some date, but for the widgets i want to be able to use manual drag-n-drop sorting. Widgets are all child pages from a certain parent page. Is this possible and how would i be able to approach this? Would it be possible to build manual sorting into MarkupAdminDataTable or should i use PageTable instead? update: Im looking in to ProcessPageSort to see if i can use that. Seems it needs an AJAX call. update: Changed title of post
×
×
  • Create New...