-
Posts
6,221 -
Joined
-
Last visited
-
Days Won
308
Everything posted by bernhard
-
hi all, i managed to hook ProcessPageList::find to return the right set of pages but i don't know to set "showRootPage" to false via hook if i set this line to "false" it works as expected, but i want to set this based on the role of the logged in user and of course i don't want to hack the core: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Process/ProcessPageList/ProcessPageList.module#L61 I'm making my first steps how to hook into methods but i don't know how to set properties of the class via hook in general? thanks for your help!
-
sorry, forgot to mention i'm on ProcessWire 2.6.1 dev
-
just tried it and i like it! (no wonder ) update from the previous version on dev went smoothly. thanks for implementing this into your module! on my live server i got this error on installation: Error: Class Fredi contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (ConfigurableModule::getModuleConfigInputfields) (line 159 of /var/www/vhosts/+++/httpdocs/site/modules/Fredi/Fredi.module) This error message was shown because you are logged in as a Superuser. Error has been logged. PHP Version 5.3.10, ubuntu
-
hmm, good point most of the time that would work, i think. though there are situations where i simply don't have a parent in my portion of code. say i have a 2-column setup like this: ___________ |_________| | | | |___|_____| |_________| and i have a widget like this: <h1>title</h1> <p>body</p> that's all the code i have in my template-markup-file. i would have to wrap this into an additional container, because i don't know if i place it in the left or in the right column! in my case it looks for its parent regardless of wether it's placed left or right (that's defined via backend and stored in the DB). <?= editlink($page->id) ?> <h1>title</h1> <p>body</p> if you have more of those widgets in one column you would have to wrap them into their own divs anyhow - so both approaches would be quite the same. maybe that discussion is getting a little bit theoretically here how would you place the edit-button in your approach? a javascript injecting some code into the dom with the data-edit-id="x", right? wouldn't you also have to adjust paddings in that case? edit: i like your approach. if you did something like this <div class="..."<?= data_edit_id($page->id) ?>> resulting in <div class="..." data-edit-id="1001"> // logged in <div class="..."> // not logged in you would also keep your markup clean!
-
that's the benefit of my approach: you don't have to touch the markup of your parent dom-element. just add one line of code (<?= editlink() ?>) and you are good - regardless WHERE you put it. that's especially useful when you have a widget-system like i have in the example. i have all the widget-markup in one folder and it can be that the first line is <?= editlink($widget->id) ?>. could be hard to find the right parent to add some code via php with php i would have to add data attributes or classes or such to all the parents i want to be "hovereditable". and you would also have to check if the user has edit-access. lots of unnecessary work compared to 1 js function and 1 php echo for each editlink. ---- it is absolutely positioned, but in a relative positioned div, so that it remains in the current DOM element. otherwise all edit buttons would stick to the topright of the window! blue = parent DIV green = relative helper DIV edit-button = absolutely positioned INSIDE the GREEN helper. due to padding of the blue container it has to be positioned with negativ margins for top and right so that it appears to be inside the blue parent
-
Image field - select image from another page
bernhard replied to cb2004's topic in Wishlist & Roadmap
what would be a usecase for this? btw: like your flipzoom coming soon page -
great! looking forward to seeing this, thank you you were totally right - i thought fredi had a different concept. with renderall() that totally makes sense! the day for my first module (that's worth being called a module) will come anyway you are right regarding document.ready - it was more of a quick and dirty proof of concept as it is only outputted for admins but to be honest i don't know if it would be much better to pack all addClass() commands into one document.ready() function than having them inline... regarding the .css("right") and .css("top"): that's to place the edit-botton on the very top right corner if the parent container has some padding:
-
didn't know about renderAll() from fredi, thank you! would be nice to have this on the documentation page i thought that you always have to setup all the fields that you want to have edit-access for and i wanted to avoid this work ^^ there's also one major difference: fredi inserts a plain edit link and screws up your design! take this example from the basic profile: <!-- main content --> <div id='content'> <?= $fredi->renderAll($page); ?> <h1><?php echo $title; ?></h1> <?php echo $content; ?> </div> all the content moves down i'll bring apeisa in - maybe he can bring best of both together
-
here you go: it's very simple, yet extremely comfortable for clients. you just need one simple javascript function: function editLink($pageid) { if(wire('pages')->get($pageid)->editable()) { // add page if action == add // check permission first! ob_start(); $editid = "editlink_" . uniqid(); ?> <div style="position: relative;" class="editlink" id="<?= $editid ?>"> <div style="position: absolute; right: 0; top: 0; z-index: 100;" class="uk-text-right"> <a href="/admin/page/edit/?id=<?= $pageid ?>&modal=0" target="_blank" class="uk-button uk-button-primary editmodal" style="color: white;"> <i class="uk-icon-edit"></i> edit </a> <?php // next floating button here ?> </div> </div> <script type="text/javascript"> $(document).ready(function() { $("#<?= $editid ?>").parent().addClass("editlinkparent"); // paddings must be adjusted when window is resized $(window).on("load resize", function () { // remove top and right margin var paddingright = $("#<?= $editid ?>").parent().css("padding-right"); var paddingtop = $("#<?= $editid ?>").parent().css("padding-top"); //$("#<?= $editid ?>:first-child").css("border", "1px solid blue"); $("#<?= $editid ?>:first-child").css("right", "-" + paddingright); $("#<?= $editid ?>:first-child").css("top", "-" + paddingtop); }); // colorbox /*$(".editmodal").colorbox({ iframe:true, width:"90%", height:"90%", onClosed: function() { location.reload(); }, });*/ }); </script> <?php return ob_get_clean(); } else return false; } and little CSS: // edit link .editlink {display: none;} .editlinkparent:hover {outline: 3px solid #ddd;} .editlinkparent:hover > .editlink {display: block;} note that i'm using markup for UIKIT css framework. what it does: let's say you have a blog-template showing all the children as postings. all you need to do when you want them to be editable on mousehover would be this: <?= editlink($page->id); ?> <section class="uk-grid uk-margin-left uk-margin-right uk-margin-large-top"> <div class="uk-width-large-3-4"> [...] <?php foreach($posts as $post): ?> <div class="uk-grid"> [...] <div class="uk-width-medium-3-4"> <?= editlink($post->id); ?> <h4><a href="<?= $post->url ?>"><?= $post->get('headline|title') ?></a></h4> [...] </div> </div> <hr> <?php endforeach; ?> the result is something like that: note that it needs only 2 lines of code! you can easily add this to any existing website in minutes... in FREDI you have to define your editable fields. that can be an advantage, but i prefer to only rely on the ID of the page (or the posting or the widget...) and have the user redirected to the right page in the backend. as you can see in the commented section of the function i also had this working with a colorbox and using modal=1, but it's more foolproof having it open in a new tab. using only the ID has the advantage, that if something changes with my field settings i don't have to change anything on frontend. how does it work? it injects some jquery javascript inline (it's only for logged in users so that won't affect your "public" markup of the page!) add HTML for the edit-button with edit-link add javascriptadd "editlinkparent" to parent DOM element this makes it possible to show the border around the affected content on mouse hover remove spacing so that the edit-button is on the very topright position of the highlighted div that's all again: i would love to pack that into a module so that it gets reuseable across other CSS frameworks with different markup and you don't have to care about adding the function and the css, but i don't know when i can find time for that. if anyone wants to try - all the info is above and i'm always willing to help
-
hi pete, it's not fredi - it's a quite different approach and i love it i'll go more in detail on this asap
-
made a little screencast of my widget system here: https://processwire.com/talk/topic/10006-maletschek-nautics-boat-center-at-neusiedlersee-in-austria/?p=95531 i'm using pagetable now instead of repeaters. logic is the same.
-
it was, but made some problems and other parts were more important. you are right, i think a search would totally make sense and maybe we will ad it one day. thanks for the input! thank you! i changed it to SVG but it's not better. i think that's the fault of the logo itself because in my editor it also does not look very nice? do you see any difference? thank you i'm using pagetable instead of repeaters now because the UI is much clearer and they do not waste so much space. did a little screencast for some more insights - also on the edit-shortcut-links
-
https://www.maletschek.at It's online now for quite a time and my biggest PW-project so far. It has loads of content (sitemap) and the editors are loving how easy it is to manage - client quote: "it's a quantum leap forward" edit: screencast added here: https://processwire.com/talk/topic/10006-maletschek-nautics-boat-center-at-neusiedlersee-in-austria/?p=95531 Highlights shortcut edit-links almost everywhere on frontend with a single line of code in the template file (planning to release a module for this one day i find the time... or if anyone is interested in doing this i can share the code i have so far) and showing what part of the site is going to be edited on mouse hover point of contact for every section - option to inherit it to the whole sub-branch of the tree for example "jakob" is point of contact for boats and he will by default also be POC for every single boat posted in this section. if there is a different POC for one single page in this branch (eg /boats/small-boats/) that's also possible by checking the checkbox - so all boats on sub-pages (/boats/small-boats/boat1) will again have jakob as POC Caching with custom Cache Reset Module (necessary due to the previous point in the list) at least for me that's a highlight because that was the first time i needed to hook something... https://processwire.com/talk/topic/8997-clear-cache-for-all-children/ widget system with complete control of where to display the widget: in this example the "point of contact" widget is shown an all pages ( site "/" - "show" - "also on subpages" ) except section "blog" ( site "blog" - "dont show" - "also on subpages" ) yumpu online catalog textformatter module like on this page: https://www.maletschek.at/shop/bootszubehor/pfeiffer/ see forum thread here: https://processwire.com/talk/topic/9888-textformatter-yumpu-embed/ i hope you like it and i'm looking forward to hearing your feedback and of course thank you all for your help! ps: sorry, there's only a german version of the website
- 24 replies
-
- 12
-
but how do you handle situations like when somebody deletes some files, then you restore a DB backup and the files referenced in the file-field are not stored in the filesystem any more?
-
are you planning to add this kind of functionality to your module some day? any planned date for this? i'm just curious. no real need for me right now because i'm using plesks backup feature. i was just wondering because the database is just one part of the whole...
-
custom php code to find selectable pages + autocomplete
bernhard replied to bernhard's topic in General Support
hm. so do i understand you correctly that your reference module won't work with page autocomplete? tried your changes with no success, sorry. but don't worry. -
how do you guys manage backups of your files (assets)?
-
custom php code to find selectable pages + autocomplete
bernhard replied to bernhard's topic in General Support
hm. i have a fresh 2.6.0 installation. created pagefield with autocomplete and added it to basic-page template created pages /test, /test/child-1, /test/child-2 set selector to parent=1001 works! "child" finds "child page example 1+2" from the intermediate profile created integer field "rootparent_int" and added it to basic-page template put 1001 into that field and saved the page set selector to parent=page.rootparent_int tried "child" as search for autocomplete and got no results also tried parent=rootparent_int, also no results reference module is installed, though i don't know if that is required for the steps above? what am i doing wrong? sorry for that many questions for such a small issue and thank you for your patience! -
custom php code to find selectable pages + autocomplete
bernhard replied to bernhard's topic in General Support
thanks soma for that advise. @lostkobrakai hm... can't get it to work. i'm using this selector in my pagefield setup: has_parent=page.rootparent rootparent is a reference field (we are talking about this module: https://github.com/LostKobrakai/FieldtypeReference) with php code return $page->rootParent; and template field pairing basic-page=rootparentid i created field "rootparentid" because i was not able to retrieve basic-page=id result: the field shows up in the page and shows "1015" - that's the value i put in the rootparentid field on the wanted page. of course this should be dynamically set in the end, but for testing it even does not work with hard values. it also does not work with pagelistselect, so it's not related to autocomplete pagefield. can you please explain how to set up your module for the second use case (https://github.com/LostKobrakai/FieldtypeReference#page-fields-using-the-selector-value-option). thanks! -
aaah, thank you - i was mixing up the wordings "inputfield" and "fieldtype"
-
custom php code to find selectable pages + autocomplete
bernhard replied to bernhard's topic in General Support
it seems to work differently because the result is different: has_parent=1015 -> result for "site" = "site1 content" and "sitemap" (that's a correct result) return $page->rootParent; -> result for "site" = "site1 content" (missing sitemap from site1 branch) so for me it would be perfect to be able to use the "has_parent" selector with a dynamic ID set to the rootparent of the current page. i tried using this selector: has_parent=rootparentfield where rootparentfield is a simple textfield storing the id of its rootparent. i thought i could maybe populate this field via hook (or lostkobrakais new module) but the selector doesn't work (result shows pages from other branches as well) -
but it refers to coding in the admin? i haven't done any form coding yet so that's why i have no idea my question was more about if there was a kind of installable inputfield (click, click solution) with a textarea that you can then place to a template (click, click) and then it renders some markup for you. edit: InputfieldMarkup is not that kind of a field, is it?
-
sorry for hijacking this thread, but this is for frontend forms, right? is it also possible to have some custom markup in admin forms, eg links in descriptions or such?
-
what does inputfieldmarkup do and where can i find more info on that? google didn't give me good results...
-
does anyone else encounter some display glitches on the processwire blog? after reloading they are gone most of the time... sometimes i noticed links or highlighted text was overlapping some text in front of it... i'm on chrome42