Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/08/2015 in all areas

  1. There's that idea for a social site (hard to come up with a correct term without giving too much away) I've been carrying around for ages. One thing that has always held me off was knowing that I'd need a tightly integrated forum. I've plugged a few forums onto existing sites and always regretted taking the job. So now that I've discovered PW, I decided to do it the other way round - build the forum on PW, then add everything else on top. I'm planning it to be highly interactive, so it's not something done in a week, yet it's simply incredible what PW allows you to do in a matter of a few days. Here's what I have so far (don't look to closely on the design, if I really go live with my idea, I'll have someone else with appropriate skills do the visual design). And don't mind the naming, I've only used PWForum as a working title in lack of inspiration. Start page (dynamic menu, sidebar configured using selectable widgets) It's reasonably responsive, not something I have experience with, so it's a learning curve I already asked you to overlook the visual issues, didn't I? (but hey, things are there and it validates) There's already a bunch of features like friends and badges built through page fields, but lots of the frontend logic still has to follow. A working private chat (jquery ajax polling) is already there. This is probably going to make it into the modules directory, even if it's just as proof-of-concept. Doing that I learned about the different ways of "magically" including scripts and styles. For production use, I'll have to implement some kind of memory caching in front of the webserver for all the ajax calls, which is also a new playground. Both chat and forum messages use bbcode-like markup. I'm building my own textformatter and editor bundle for that to get it lean and flexible enough. The textormatter already allows you to configure smiley patterns in the backend. There are going to be a lot of profile settings. I'm sure I'm going to have to add more than one tab. This is just a project I'm doing for fun, so I don't have a timeline, it's more about toying with things and finding clean solutions. If things work out, I hope to have everything worked out some time around Easter and bundle it as a site profile for others to disassemble
    5 points
  2. This is about viewing large images with a frontend viewer that pans and zooms a view made from image tiles stored on the server. Like you're used to seeing with maps. The module is a work in progress and I'm fishing for advice and suggestions about integration etc. The viewer is OpenSeadragon, which works with lots of different tiling schemes. Examples at the link. Tiles go in folders within the assets/ folder. I'm keeping them in their own branch now (assets/zoom/{id}/{tag}/) but it doesn't have to be that way. The module (patterned after FieldtypeEvents - Thank You!) stores meta information about the tile sets and has a render method to make markup for your template. I have an image for this but the forum tells me: "You are not allowed to use that image extension on this community." It's .jpg Render them like this: $zees = $page->Zooms; if(!empty($zees)){ $spex->addScript($config->urls->templates.'scripts/openseadragon.js'); foreach($zees as $z){ $a = $z->renderZoom(); $spex->docReady($a['js']); echo $a['html']; } } Nothing magic about using spex there. I just happen to be using it. The javascript being handled there should run after the page is loaded. The html markup is just a couple of divs, one for buttons and one for the image, and possibly a label. You could do it in your template code but it seemed handy to build default markup into the module. I already have sets of tiles which were made for an old Zoomify viewer. I've slightly customized the tile loader to handle the different naming conventions so OpenSeaDragon can use them like dzi tile sets. Pretty much anything you need to do like that involves one small JS function which provides the URL to the image. So far, I can put tile files in assets, enter the meta info in the page editor, view the page and see the zooms. The markup has reasonable ids and classnames so you can style zooms individually or globally and multiple zooms on the same page function just fine. Next Steps: People will want to add/replace images. I'm thinking of using an ordinary images field to upload and store the originals and have a scheduled task do the tile making offline. Tiling takes more time and memory than I would want to use in a hook on save approach. I would use the image's tags field as a place for the user to put a name to be used both as a label and as a subfolder name for the tiles. Thanks
    4 points
  3. Your code did miss the r, that's why I asked. Multiple paginations are doable, but you need to make use of the getVars setting and manage the start position of both find calls on your own. function pageStart($limit){ $limit = (int) $limit; if($input->pageNum === 1 || $limit < 1){ return 0; } return ($input->pageNum - 1) * $limit; } $limit = 15; $first = $pages->find("…, limit=$limit, start=" . ($input->get->first ? pageStart($limit) : 0); // Will be merged to form getVars // If you don't otherwise use the feature to ship e.g. filter settings to paginated pages // you could also directly manipulate the getVars via the pager settings. $input->whitelist("first", 1); // generate pagination 1 $limit = 12; $second = $pages->find("…, limit=$limit, start=" . ($input->get->second ? pageStart($limit) : 0); $input->whitelist("second", 1); $input->whitelist("first", 0); // generate pagination 2
    4 points
  4. You could have this in a single selector like so: $tables = $pages->find("fcheckbox=1, parent=[parent.name=pricing]");
    4 points
  5. This is a description of a 'members' setup, where a 'member' is a processwire user who is able to manage their own branch of the page tree. Based on a simple site that looks a bit like this. HomeMembersMember APage A1 Page A2 Member B Member CPage C1 Etc. Section XPage X1 Page X2 Section YPage Y1 Members A, B and C can add, edit, sort and delete children of their page Member A/B/C. They may also edit their page Member A/B/C. Without any additional roles they have just ‘view pages’ access elsewhere. Take Section X above as an example, and two roles ‘editor’ and ‘sub-editor’ where the role ‘editor’ can add/edit/delete pages beneath Section X; and the role ‘sub-editor’ can edit pages beneath Section X. Assigning either of these roles to a user who also has the ‘member’ role does not interfere with either scheme. Setup Before adding users I do the following: Enable the permission ‘page-edit-created’ Create a role ‘member’ and grant it ‘page-edit’, ‘page-delete’, ‘page-edit-created’, and ‘page-sort’ permissions Create a template ‘member’ and enable access controls granting role ‘member’ ‘edit pages’ and ‘add children’ in addition to the default ‘view pages’Use the ‘Revoke permissions by role’ function to remove ‘page-delete’ for the role ‘member’ Enable the advanced option ‘Allow the ‘created user’ to be changed on pages’ Create a template ‘members’ and under family settings allow children (specify the ‘member’ template as the allowed template for children/‘members’ template as the allowed parent for template ‘member’); optionally allow only one page using the template ‘members’ Create (or reuse) templates for the children of template ‘member’; specify these as the allowed templates for children of template ‘member’; grant ‘edit pages’ and ‘create pages’ to the role ‘member’ on these templates. Insert the following between lines 638 and 640 in file wire/modules/PagePermissions.module } else if($page->template->name == 'member') { if($user->id == $page->created_users_id) { $addable = true; } Add/Edit a user (e.g. ‘Member A’) and assign role ‘member’ Create a page (e.g. ‘Members’) in the tree with template ‘members’ Add a child page (e.g. ‘Member A’) to the page ‘Members’ On the page ‘Member A’ under Settings, change the ‘Created by User’ to the user ‘Member A’ Repeat for all users assigned the role ‘member’. Er, that’s it. It seems obvious to me that this could be made into a module. I haven't the experience, skills, knowledge required to complete that quickly, but the above works nicely in the way I want it to and this may be of benefit to others here. There may be unintended behaviour that I haven’t located yet. For example (though this is possibly not related to this setup) I’ve seen that when a textarea field has CKeditor as the inputype the ‘member’ users are able to insert images from any page, which is not the desired behaviour. I’ve seen some forum posts that address this, or similar such that I’m confident that this could be overcome. If it were a module, I think this defines what the module does. On install/configure Ask for a plural and singular version of your membership. Check for and enable if necessary the permission ‘page-edit-created’ Check for and create a role ‘singluar’ and enable permissions ‘page-edit’, ‘page-delete’, ‘page-edit-created’, and ‘page-sort’ Check for and create a template ‘plural’ Check for and create a template ‘singular’ and assign ‘edit-pages’ and ‘add pages’ to role ‘singular’‘singular’ template, Allow the ‘created user’ to be changed for pages using this template. Modify the Family rules for the two templates:‘plural’: Can this template be used for new pages?: One (no more allowed) ‘plural’: Allowed template(s) for children: ‘singular’ ‘singular’: Allowed template(s) for parents: ‘plural’ Modify the file wire/modules/PagePermissions.module as per the above In action When a user is assigned the role ‘singular’, (e.g. user ‘Nic’) the following actions are executed. Check for and add a page ‘Nic’ with template ‘singular’ under parent ‘plural’ Change the created user ID for page ‘Nic’ to that of user ‘Nic’. Other ideas Ask at install time where the root page ‘plural’ should be created and create it. What to do when removing the module. Tackle the CKeditor insert image issue EDIT/ADDITION: Either a change to the user template to include a "Full Name" for creating member pages (title field); or less intrusively, add a "Full Name" field to the "member" template and allow the member to enter their own.
    2 points
  6. This is a helper class to using debug log. require_once 'Debug.php'; Debug::init(); Debug::log($myVar); Debug::log($myArray); <?php /** * Helps with the debugging log */ class Debug { protected static $name = 'debug'; public static function init() { if(!file_exists(self::filename())) { self::log('Debug File Init'); } } public static function log($param) { if (is_array($param)) { $param = json_encode($param); } wire('log')->save(self::$name, $param); } public static function filename() { return wire('log')->getFilename(self::$name); } public static function name() { return self::$name; } }
    2 points
  7. Try to set max exec time within the loop itself, inside your if block $page->setOutputFormatting(false); set_time_limit(60); If memory is a problem, you might also want to free some memory by adding the following after WriteLog. WriteLog("{$internal} saved"); wire('pages')->uncacheAll(); // free some memory
    2 points
  8. Are you calling this from the command line or via http? In the latter case, my guess would go towards script execution time constraints. Are you getting a "saved" message for those failed pages? I don't think there's a limit for the number of page saves. I know I've imported a few thousand pages in one go in my last project, with each import resulting in more than two page saves.
    2 points
  9. This module lets you restrict users to a certain branch of the page tree - it can limit editing permissions, as well as the page list view to this branch. http://modules.processwire.com/modules/admin-restrict-branch/ https://github.com/adrianbj/AdminRestrictBranch Restricted View Non-restricted View Note that this module does not add permissions (unlike how PageEditPerUser and PageEditPerRole work), so the user must have template level permissions to edit the pages in the restricted branch. What this does allow though is giving all users/roles editing access for the home template and allowing that to inherit all the way through the page tree and let this module restrict to specific branches. As you can see from the screenshots you can specify how to determine the branch to restrict the user to - either via a matched role name, or via a dedicated page select field on the user's profile. The match role name works like this - if you have a series of branches called: Branch One, Branch Two, etc, users with a role named: branch-one will only have access to Branch One. You can also decide whether to restrict page tree viewing as well and editing privileges (default) or just editing privileges. The Branch Exclusions option is important for things like external PageTable parent branches etc. Main module config settings User specific branch setting on user profile page This module came out of my personal needs as well as this discussion: https://processwire.com/talk/topic/11428-project-design-main-shop-hundreds-of-affiliates/ As always, feedback is very welcome.
    1 point
  10. Does this help? I use it myself in my Matrix module.
    1 point
  11. There's a module for this
    1 point
  12. In your home.php: if($config->httpHost == "domaina.com"){ $session->redirect($pages->get("/asection/")->url); } else if($config->httpHost == "domainb.com"){ $session->redirect($pages->get("/bsection/")->url); }
    1 point
  13. LazyCron does execute all codes it should execute independent on which page is visited, so that's certainly not the issue. But you're missing all the offsetFormatting false calls.
    1 point
  14. renderPager() ? Edit: And you need to enable pagination for the template you're adding the pagination to and not the templates you want to paginate.
    1 point
  15. Something like that? $children_of_price_lists = $pages->get("parent=[has_parent=/pricing/, template=pricelist], my_checkbox=1");
    1 point
  16. Ok found it I forgot to retain the User Authentication Salt when I moved the site from local server to online server. All good now.
    1 point
  17. Shouldn't be too hard to incorporate into the core. Meanwhile, I've tweaked together a tiny module that adds a delete button next to the crop icon. It's not really tested with different permission settings though. github repo for ImageActionDelete
    1 point
  18. Different set of tools here (but based on somas great wordlimiter! I don't use it in a module via hook just in my _func.php and i use it on several different strings to get clean values for example a sumary of the body text if no meta description is set...and so on. regards mr-fan /** * Wordlimiter cuts a textarea only after complete words not between * used seo function and in some templates */ function wordLimiter($str = '', $limit = 120, $endstr = '...'){ if($str == '') return ''; if(strlen($str) <= $limit) return $str; $out = substr($str, 0, $limit); $pos = strrpos($out, " "); if ($pos>0) { $out = substr($out, 0, $pos); } $out .= $endstr; return $out; } /** * Alternative with regex for striptags function * used for seo function and in some templates */ function ripTags($string) { // ----- remove HTML TAGs ----- $string = preg_replace ('/<[^>]*>/', ' ', $string); // ----- remove control characters ----- $string = str_replace("\r", '', $string); // --- replace with empty space $string = str_replace("\n", ' ', $string); // --- replace with space $string = str_replace("\t", ' ', $string); // --- replace with space // ----- remove multiple spaces ----- $string = trim(preg_replace('/ {2,}/', ' ', $string)); return $string; }
    1 point
  19. 1 point
  20. That's one solution, the other would have been to determine the field type through the page's template. $tpl = wire('templates')->get($templatename); if( $tpl->fields->get($fieldname)->type instanceof FieldtypeFile ) { /* true for file and image field types, import as file */ }
    1 point
  21. Speaking of images, here's some feedback from a client training session. Again, Images being the only area that confused my client. Process of steps.Everything good until after step 4 Click Insert Image in CK editor Click Upload Image Select a file from your computer Hit Save once the image is uploaded At this point, its unclear what the required step is. "I can see my grid of uploaded images but no indication that I still have to select one. It's made a little less obvious by the two Upload Image buttons too." and... "When I do select my image, I am presented with the cropping UI and more options (Insert this image, Select another image, Cancel) and I'm not sure what to do next".
    1 point
  22. This looks very nice. I really like consistent UI / UX and the image field did always lack by the tiny bits. My greatest bugbear was always the dropzones. E.g. if I not hit the input exactly it'll load the file as local resource and all changes to my page are gone. Also I've hesitated to use croppable image in the last months just because I really don't like the fact, that it needs to replace the whole UI, instead of gracefully building on it. Therefore I really like your proposed changes to the cropping interface. As you've asked for other opinions I've some thought for you: 1A Having tabs resolves the issue of showing the user his options, but I know it from myself, that it would bug me really soon (if I would use RTE's more often). If I want to add an image I click the image button in the ckeditor toolbar. While the modal opens I switch to Finder, drag my file to the browser and sadly notice, that the droparea is behind the tab. Then I'd try to not drop my image anywhere, where I would open it in the browser or to any wrong folder or the desktop. Change to the upload tab. Repeat first steps. Not very nice. 1B Your alternative would solve my issue with 1A, but it looks really imbalanced from a visual standpoint. Unlike all your other images this looks like a really rough mockup. Maybe a vertical layout would work better than side by side, but not necessarily. 1C Grids are nice to get an overview, but they lack to highlight the most important thing an editor need to be reminded of: descriptions. It also lacks tags, but I'm really not using those. But back to descriptions. I don't know about you guys, but I always use them for alt tags and these should really be filled if one cares for seo. I'm still not sure how this could be solved better, but I really think that only-image grids aren't the obvious way to go. 2 As said before I really like the cropping option on the side and the more tidy placement of all things. The only thing I have to critic about it are the buttons. There are two cancel buttons and the "Apply" button fails to communicate what it does. "Save and Replace" like the bigger button below? I also think the "replace" part should not be part of an button, but part of your options. The "Save" button should only have a single type of action – saving the crop with the current settings – while I may decide while cropping, that I don't want to replace the current crop, but save a new one.
    1 point
  23. I just dropped in for a quick minute, but wow! I'll look closer at these later tonight when I have time.
    1 point
  24. Sure it’s possible. I’d love to see a more page-field-like PageTable, actually. Here is a (really, seriously) half-assed module that lets you add a page to a PageTable field. Be aware, when you remove your page from the field, it will trash the entire page just like the standard PageTable does. Do NOT use this anywhere but in a testing environment. It also has a hard coded template that you shoult probably change to whatever your PageTable accepts. $this->addHookAfter('InputfieldPageTable::render', $this, 'PageTableRender'); public function PageTableRender($event) { $pageTable = $event->object; $out = "<select name='{$pageTable->name}_addcustom'>"; $pages = $this->pages->find('template=PAGETABLETEMPLATE'); //change this foreach ($pages as $p) { $out .= "<option value='{$p->id}'>{$p->title}</option>"; } $out .= '</select>'; $out .= "<script> $(document).ready(function(){ $('select[name=\"{$pageTable->name}_addcustom\"]').change(addPage); function addPage() { var input = $('input[name=\"{$pageTable->name}\"]'); var container = input.siblings('.InputfieldPageTableContainer'); var dataurl = container.attr('data-url'); var pageid = $('select[name=\"{$pageTable->name}_addcustom\"]').val(); var ajaxURL = dataurl + '&InputfieldPageTableAdd=' + pageid; $.get(ajaxURL, function(data){ container.html(data); container.effect('highlight', 1000); }); alert('wtf did you do'); } }); </script>"; $event->return .= $out; } As you can see, the heavy lifting in the PageTable field is done via Ajax. Maybe it’s a starting point. I really need to go to bed
    1 point
  25. I think the problem is this line: $cover=$item->LargeImage->URL; For instance, try this, and I'm guessing it'll tell you it's an object: var_dump($item->LargeImage->URL); When accessing elements like this, SimpleXML returns objects, not strings. You have to typecast it to a string, like this: $cover = (string) $item->LargeImage->URL; Many of the other elements you are pulling are already being typecast as strings by way of str_replace, preg_replace, strtolower, $sanitizer->text(), etc., so that's good. But you'll want to typecast these ones as strings too: $publisher=$item->ItemAttributes->Publisher; $isbn13=$item->ItemAttributes->EAN; $isbn10=$item->ItemAttributes->ISBN; $cover=$item->LargeImage->URL; This is one of those things about PHP's SimpleXML that has stung me more than once.
    1 point
×
×
  • Create New...