-
Posts
1,065 -
Joined
-
Last visited
-
Days Won
11
Everything posted by Zeka
-
setViewData([ 'news' => $news->explode(function ($news_item) { return WireData([ 'title' => $news_item->title, 'date' => $news_item->if('publish_from=today', 'yes', 'no'), 'link' => $news_item->url ]); }) ]); This part looks very familiar to me)))) Try something like pages('id>1000')->each(function ($item) { $today = strtotime('today'); d(date("Y-m-d", $item->modified), $item->if("modified>=$today, modified<tomorrow", 'yes', 'no')); });
-
[SOLVED] Remove Select Page/File from Insert Link Modal
Zeka replied to Klenkes's topic in General Support
$wire->addHookBefore('InputfieldForm::render', function(HookEvent $event) { $form = $event->object; if($form->id !== 'ProcessPageEditLinkForm') return; $inputfields = $form->children('name=link_page_id|link_page_file'); foreach ($inputfields as $inputfield) { $inputfield->collapsed = Inputfield::collapsedHidden; } $tab = $form->child('id=link_attributes'); $tab->collapsed = Inputfield::collapsedHidden; }); -
how can add custom field in front-end user login or register.
Zeka replied to abdulqayyum's topic in Modules/Plugins
- 6 replies
-
- loginregister
- processwire
-
(and 2 more)
Tagged with:
-
Hi. I'm playing with the layout in admin and want to get the same columns as on the screenshot, but can't figure out how. For sure that is something obvious that I miss. Thanks!
-
Idea: Language config in repeater(matrix) items headings
Zeka replied to gerritvanaaken's topic in Multi-Language Support
Definitely would love to have such options. Language togglers could be hidden under same panel as 'change matrix type' panel. -
@Noel Boss I have an issue, I see this strange red shadow which goes from this line. https://github.com/noelboss/AdminThemeBoss/blob/master/uikit/dist/css/uikit.black.css#L16522 Is there is any reason why this CSS rule is set?
-
@Guy Incognito AFAICS, this functionality relies on cookies. There is'repeaters_open' cookie which holds ID's of opened items. So, probably you can try to use https://processwire.com/api/ref/wire-input/cookie/ in hook to manipulates it.
-
Adding "object" in from of returned json from "api"
Zeka replied to louisstephens's topic in Dev Talk
$allowed_fields = [ 'title', 'seo_title' ]; $out = $pages->find('include=all, limit=10')->explode(function($p) use($allowed_fields) { $fields = $p->fields; foreach($fields as $f) { if(in_array($f->name, $allowed_fields)) { return [ 'id' => $p->id, 'title' => $p->title ]; } } }); echo json_encode($out); -
Best Practice to determine if admin from init method?
Zeka replied to Noel Boss's topic in API & Templates
@Noel Boss I'm using this code in hooks to Templatefile::render and didn't have any issues with it. if (strpos($_SERVER['REQUEST_URI'], $this->wire('config')->urls->admin) === 0 || $this->wire('page')->template->name == 'admin') return; -
Guys, I need some clarifications here. I'm building catalog menu and depending on whether a page has children with 'category' template I change some part of my selector. Code that I use: <?php namespace ProcessWire; $layout->setTemplate('sidebar'); $selector = [ 'template' => 'product', 'sort' => 'title', 'categories' => page('id'), 'limit' => 9 ]; if (page()->children->has('template=category')) { $selector['categories'] = page()->children('template=category')->add(page()); } $products = pages($selector); $sub_categories = page()->children('template=category'); bd(page()->children()); // 7 bd(page()->children('template=category')); // 8 As you can see in the first 'bd' I get 7 children and that is the right result. But it the second I get 8 children ( 7 children and current page which was added in if statement). I can't understand it from PHP side. For me, it's unintended behaviour as I'm calling function and waiting for a new result, but instead, I'm getting the result from an object from the previous call.
-
Great update. Thanks.
-
@kkalgidim Not sure that it would suit your case, but worth to mention that there is the 'owner' selector, so you can use it instead of updating field. https://processwire.com/blog/posts/processwire-3.0.95-core-updates/
-
Edit multilanguage page names in custom process module UI
Zeka replied to lokomotivan's topic in General Support
You don't have to write custom module, you can use ProcessPageEdit as process for that page and omit executeEdit method in your process module. -
Edit multilanguage page names in custom process module UI
Zeka replied to lokomotivan's topic in General Support
@lokomotivan public function executeEdit() { // breadcrumb $this->fuel->breadcrumbs->add(new Breadcrumb($this->page->url, $this->page->title)); // Execute Page Edit $processEdit = $this->modules->get('ProcessPageEdit'); return $processEdit->execute(); } Probably you will use something similar for adding new pages, but with ProcessPageAdd. So, by using this aproach for adding new pages you will get an issue with initial languages values. As you can see all non-default languages are active. But, after page save they become disabled. I was trying to resolve this issue but with no luck. So I went with creating addition page under the module page which reffers to custom module which extend ProcessPageAdd class ProcessCustomPageAdd extends ProcessPageAdd { /** * @return array * */ public static function getModuleInfo() { return array( 'title' => __('Page Add', __FILE__), 'summary' => __('Add a new page', __FILE__), 'version' => 108, 'permanent' => true, 'permission' => 'page-edit', 'icon' => 'plus-circle', // 'useNavJSON' => true, ); } public function init() { if ($this->wire('page')->parent->name == 'news-manager') { $this->set('parent_id', 1036); } else { ..... } } } Hope it helps. -
Edit multilanguage page names in custom process module UI
Zeka replied to lokomotivan's topic in General Support
@lokomotivan Not sure, but try to implement WirePageEditor by your module class class YourCustomLister extends Process implements WirePageEditor -
@Leftfield The path hook should be in ready.php and all logic should be in home.php or in the template file that you are using for root page. if (input()->urlSegment(1) && input()->urlSegment(2) == 'pr' && input()->urlSegment(3)) { $pagename = input()->urlSegment(1); $hash = $input()->urlSegment(3); $match = pages()->findOne("template=product, name={$pagename}, hash_field={$hash}"); if (!$match->id) throw new Wire404Exception(); echo $match->render(); return $this->halt(); } Also you should enable URL segment for root ( home ) page. Generate hash and save it to hash field you can by hooking in Pages::saveReady. You can find a lot of exaples in the forum.
-
@Leftfield I think that URL segmetns is the way to go. wire()->addHook("Page(template=product)::path", function($e) { $page = $e->object; $e->return = "/{$page->name}/pr/{$page->hash_field}/"; }); Then you have to enable URL segments for your home template. And in template file if (input()->urlSegment(1)) { $pagename = input()->urlSegment(1); $hash = $input()->urlSegment(3); $match = pages()->findOne("template=product, name={$pagename}, hash_field={$hash}"); if (!$match->id) throw new Wire404Exception(); echo $match->render(); return $this->halt(); }
-
You can check whether page rendered in admin if so, do nothing. if (strpos($_SERVER['REQUEST_URI'], $this->wire('config')->urls->admin) === 0 || $this->wire('page')->template->name == 'admin') return;
- 1 reply
-
- 3
-
-
Ok, then public function ___execute() { $out = ''; $input = $this->wire('input'); $modules = $this->wire('modules'); $form = $this->modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name", "form_application"); $btn_application_create = $this->modules->get("InputfieldSubmit"); $btn_application_create->attr('id+name', 'hook_accept_application'); $btn_application_create->value = "Start Student"; $btn_application_create->addClass("ui-priority-primary button_submit"); $form->append($btn_application_create); if ($input->post->hook_accept_application) { $form->processInput($input->post); if ($form->getErrors()) { $out .= $form->render(); } else { $this->addButtonsMethods(); } } else { $out = $form->render(); } return $out; } public function addButtonsMethods($event) { wire('session')->redirect(wire('pages')->get(123)->editUrl; }
-
Hi @Federico Why just not check for input post like $modules = $this->wire('modules'); $form = $this->modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name", "form_application"); if($this->wire('input')->post->your_submit_button) { $btn_application_create = $this->modules->get("InputfieldSubmit"); $btn_application_create->attr('id+name', 'hook_accept_application'); $btn_application_create->value = "Start Student"; $btn_application_create->addClass("ui-priority-primary button_submit"); $form->append($btn_application_create); }
-
Definitely, I would recommend PW. In my case, the client didn't like the tree structure of pages, so I had to create separate Process modules for managing news, tags, banners, categories. I have found that it's much easier to control permissions and workflow via custom modules.
- 20 replies
-
- 11
-
-
Hi. I have custom module ProcessDashboard, not ProcessDashborad from modules repository, but when I go to ProcessWireUpgrade it indicated that my module has an update as it conflicts with the ProcessModule from the repository. Is there some way to prevent it? Something like 'private' flag? Didn't find any similar thing in module.php. Thanks
-
Hi. I'm trying to get embed data for some posts from Facebook using specified endpoint https://developers.facebook.com/docs/plugins/oembed-endpoints/. It works for all type of posts, but not for posts that match this pattern https://www.facebook.com/permalink.php?story_fbid={post-id} For example, this post 'https://www.facebook.com/permalink.php?story_fbid=1461042474038729&id=188990994577223' returns 404 when requesting URL 'https://www.facebook.com/plugins/post/oembed.json/?url=https://www.facebook.com/permalink.php?story_fbid=1461042474038729&id=188990994577223' Maybe it somehow relative to additional ID parameter in post URL, but I haven't seen URLs for post only with 'story_fbid'. So, I really can't figurate out what is the issue here. Maybe somebody faced such problem and can get some ideas of recommendations?
-
@neonwired https://processwire.com/api/ref/wire-file-tools/render/