-
Posts
1,510 -
Joined
-
Last visited
-
Days Won
16
Everything posted by Ivan Gretsky
-
If it is only one project per user, you could use this module. If you need to grant a user access to 2 or more branches, you probably need to hide the tree of pages to that user and display accessible pages with a custom module. I hope I understood your question properly)
-
I checked my site that had custom styles. This is what I have there in site/modules/InputfieldCKEditor/mystyles.js: CKEDITOR.stylesSet.add( 'mystyles', [ { name: 'Inline Code', element: 'code' }, { name: 'Inline Quotation', element: 'q' }, { name: 'Left Aligned Photo', element: 'img', attributes: { 'class': 'align_left' } }, { name: 'Right Aligned Photo', element: 'img', attributes: { 'class': 'align_right' } }, { name: 'Centered Photo', element: 'img', attributes: { 'class': 'align_center' } }, { name: 'Small', element: 'small' }, { name: 'Deleted Text', element: 'del' }, { name: 'Inserted Text', element: 'ins' }, { name: 'Cited Work', element: 'cite' }, { name: 'Left Heading', element: 'h2', attributes: { 'class': 'u-align-left' } }, { name: 'Right Heading', element: 'h2', attributes: { 'class': 'u-align-right' } }, { name: 'Important', element: 'div', attributes: { 'class': 'u-important u-important--brand' } }, { name: 'Bordered Table', element: 'div', attributes: { 'class': 'u-table-bordered' } } ]); My added styles are at the end of the list. They do work, if there is only one CKEditor field on the page edited (see this issue). Also keep in mind, that the styles for ul elements are only shown when this type of element is selected in the editor working area. P.S. If everything works out, don't forget to add you custom styles to site/modules/InputfieldCKEditor/contents.css or site/modules/InputfieldCKEditor/contents-inline.css so they display as they should: ... .u-important--brand { font-size: 21px; line-height: 1.3; padding-left: 40px; } .u-table-bordered { color: blue; }
-
Search selectors and empty repetear fields
Ivan Gretsky replied to lele_ballack's topic in General Support
Maybe something as simple as this will do? if(isset($input->get->q) && !empty($input->get->q)) { ... -
Good day! I am trying to do a frontend check in a Page::render hook and return completely different markup on condition: <?php // This is site/ready.php wire()->addHookAfter('Page::render', function (HookEvent $event) { $page = $event->object; ... //Some condition here $config = wire("config"); $t = new ProcessWire\TemplateFile($config->paths->templates . "test.php"); $t->setArray(array( 'page' => wire()->pages->get("1234"), ) ); $t->setPrependFilename($config->paths->templates . '_init.php'); $t->setAppendFilename($config->paths->templates . '_main.php'); $out = $t->render(); $event->return = $out; } But I get this error: Cannot redeclare SomeFubction() (previously declared in ...\site\templates\_func.php:123) _func.php is included with include_once in _init.php. But somehow _init.php happens to run twice. Can't get my head around this one. Please help!
-
Getting the page title a repeater field is on from a pageField
Ivan Gretsky replied to a-ok's topic in General Support
Resurrecting this is an old topic) Is there now an easy way to use the title of a page a repeater field is on in a Custom Page Label Format? Like {getForPage.title} with a special keyword? Probably like {parent.title}, which works. I solved the problem with the hook, but it could've been easier) -
A bit offtop... Maybe such epic modules like Tracy Debugger (and AOS, and some else, probably) could get their own sub-forums under Modules/Plugins? Kind of like Padloper got its own under Vip Support? I am sure, it can be done and (arguably) would make it easier for people to find stuff. But would it make it easier for maintainers? What do you think, @adrian?
-
That's the point of it all - I do not want to rewrite all $this occurrences))) Thought there is some smart way to avoid this. $this2 was a try to somehow substitute $this with something I can get api variables from. But I guess this will not help if there is some module method/property calls. Maybe I could inject $this as a dependency from a hook somehow (I do not even understand if I am writing proper terms here))))))?
-
Thanks, @kongondo! Sorry for late reply. But now I am at this once again) This is what I'm trying to do in admin.php: /** * Replace the execute method of ProcessLogin module to replace * the getLoginName() call with getLoginName2(). The former method is not hookable. * The latter method is added via hook/ * * All this is done to allow users to login with their email changed on the fly * to user name (replace '@' with '-'). * */ wire()->addHookBefore('ProcessLogin::execute', 'processLoginExecute2'); ... getLoginExecute2() is just a copy of ProcessLogin::execute with minor changes. I copy it to admin.php like this: function processLoginExecute2(HookEvent $event) { $event->replace = true; /** @var Session $session */ $session = $this2->wire('session'); /** @var WireInput $input */ $input = $this2->wire('input'); /** @var User $user */ $user = $this2->wire('user'); if($user->isLoggedin()) { ... And then I get an error with $this variable. It must be it is not in scope or something.
-
As I get it, partials came first (there were no components at the time). And components were added later due to user requests. I think too that only one (the components)) should stay in the future. But I may be missing something.
-
Welcome to the forums, @rookie! The question you're asking is very interesting and important. But I think you have to read the forums a bit before continuing with it. For now it seems like any answer will be not good enough for you. So do search the forums for 'page builder' and 'content builder'. It is better to search with google though) It is possible to do it with the page structure you're showing. But without Repeater an PageTable fields (or preferably RepeaterMatrix) it will be pretty hard to maintain. So take your time to explore a bit.
- 7 replies
-
- 1
-
-
- blocks
- page builder
-
(and 1 more)
Tagged with:
-
Good day! I have a need to replace the core class method with a hook. There is an example of this in docs, It is from the class context. I need it from the template context (admin.php). I want to change the behavior of the core class method a little bit, so do not want to re-write it entirely. So I copy-and-paste the method to the function that should be used to replace it and make my minor changes. But multiple uses of $this cause an error I am not sure how to resolve. Could you please advise how to do it. Replace the method of the core class from template context not having to rewrite the entire method?
-
Just like ProcessWire)
-
This is where I started)) Thanks, I'll look into it. But I always try to first use a native solution if it exists) And PW always tried to be all-in-one thing. I am actually thinking about building a module on this feature, so do not want to have an external dependency. The 1st part I didn't understand) But the second looks promising. Could you share an example of this in a template file context?
-
Good day! Is there an easy way to add events that some listeners can subscribe to in ProcessWire? I am thinking about adding these events in the template context, so I can add some listeners later. Preferably I'd like to be able to pass some variables to the listener. I am guessing it could be done calling some hookable method of a specially-made class. But please share anything more specific on that if you got some experience, colleagues.
-
Super! Love reading those long feature lists for the new master versions! I usually read every week's posts too. But by the time a new master is out, I forget a half of new cool things that were added. So they come as new and bring the joy once again, like finding a banknote in a pocket of pants you didn't wear for while ? Great release for ProcessWire once again!
- 3 replies
-
- 11
-
-
Omit access check in (showif) field dependencies?
Ivan Gretsky replied to kater's topic in API & Templates
This should be possible to do with a hook. Look here for inspiration. Or just search for something like "hook admin inputfield show" (preferably, in Google) -
The hook priority did the trick! Thanks @adrian! I have found the post about the module autoload order. But it did not help me as you predicted (still not quite sure why, though).
-
As of now I am a user of this feature too) Thanks to @adrian's link. I did need it to fix this issue. If you read through the linked thread you'll see that I confused module autoload order with hook order. Actually I thought that the module, that gets loaded first, would add the hook first (or last). So the autoload order would affect hook order. I did play with autoload order of the modules without success. Why is it not it the case? If it was, there could a chance to add an option to override module autoload order in admin, making it adjustable without code hacks , solving this question.
-
Oh, I see. I've indeed confused the two. So looking at the thread it seems I need to modify the modules code, right? No way to sort'em afterwards? Sorry for asking the questions in the wrong thread))
-
Cool! I was sure it has made it's way into the core though, so was looking in the blog posts... Or was it just your Tracy Debugger that got privileged))
-
Thanks! I remember reading about the possibility to change the module load priority, but cannot find it( Could you direct me there to make the answer complete for someone finding it later?
-
Good day, @adrian! I have found your super-module installed on a client's site. And it lives alongside PageEditPerUser. The If no match, give all access or no access? option is set to No Access. For some users we need to apply restrict branch per user limitation via your module. But for others we need to limit page access on a per page basis with PageEditPerUser, leaving the branch option empty. But this does not seem to work. If the branch_parent field is left empty it still rules over other page edit permissions. Could you please explain, why is that happening, can we get around it (like changing the order of hooks applied or something). Or maybe suggest another way to deal with it?