Leaderboard
Popular Content
Showing content with the highest reputation on 07/26/2017 in all areas
-
4 points
-
Just for other peoples reference I've been using @adrian's coding here: as a function in my module: protected function createRepeater($repeaterName,$repeaterFields,$repeaterLabel,$repeaterTags, $icon){ $f = new Field(); $f->type = $this->modules->get("FieldtypeRepeater"); $f->name = $repeaterName; $f->label = $repeaterLabel; $f->tags = $repeaterTags; $f->icon = $icon; $f->repeaterReadyItems = 3; //Create fieldgroup $repeaterFg = new Fieldgroup(); $repeaterFg->name = "repeater_$repeaterName"; //Add fields to fieldgroup foreach($repeaterFields as $field) { $repeaterFg->append($this->fields->get($field)); } $repeaterFg->save(); //Create template $repeaterT = new Template(); $repeaterT->name = "repeater_$repeaterName"; $repeaterT->flags = 8; $repeaterT->noChildren = 1; $repeaterT->noParents = 1; $repeaterT->noGlobal = 1; $repeaterT->slashUrls = 1; $repeaterT->fieldgroup = $repeaterFg; $repeaterT->save(); //Setup page for the repeater - Very important $repeaterPage = "for-field-{$f->id}"; $f->parent_id = $this->pages->get("name=$repeaterPage")->id; $f->template_id = $repeaterT->id; $f->repeaterReadyItems = 3; //Now, add the fields directly to the repeater field foreach($fieldsArray as $field) { $f->repeaterFields = $this->fields->get($field); } $f->save(); return $f; } // usage public function install(){ $fields = array('title','body'); $this->createRepeater("text_repeater",$fields,"Text repeater","", "file-text"); }4 points
-
Generally I'd advice to keep the user template as minimal as possible. It's meant to authenticate users and hold basic infos applicable for all users, not to fulfil all your additional data needs, which can be related to an user. E.g. in your example I'd say a user might have a profile for avatar / social media or employee information for phone / address / department details. These can simply link back to the user they belong to. Having alternative user templates is possible in processwire, but it's limiting you to have just a single (more or less fixed) type for each user. As soon as your types of users can overlap that strategy is going to break down.4 points
-
Not sure I understand what you are trying to achieve. You need PHP to use PW, you cannot use it from html only. Why don't you install processwire on www,yoursite.com/api/ subdirectory? There your /index.html could be static html/js and then /api/* would go for pw.3 points
-
Hi, I guess you have permission issues. In my cPanel blog post I show my own setup, you might be interested in it.3 points
-
What @Alxndre' is suggesting is something like the below... First you get your category pages, then you loop over the categories, for each category finding pages that have that category selected in the Page Reference field. If there are some matching pages, output the category heading and the list of posts. $categories = $pages->find("template=category"); foreach($categories as $category) { $posts = $pages->find("template=article-post, category=$category"); if(count($posts)) { echo "<h3>$category->title</h3>"; foreach($posts as $post) { // whatever markup you want for the post echo "<p>$post->title</p>"; } } } This is fine for a lot of circumstances, but note that you do a database query to get the categories and then for each category you do a database query. If you have a lot of categories this would mean a lot of database queries. There is another approach that is more efficient: get all the posts sorted by category (as you are already), then for each post check if the category is different from the previous post's category. If it is different then output a heading. $posts = $pages->find("template=article-post, sort=category"); $category_title = ''; foreach($posts as $post) { if($post->category->title !== $category_title) { $category_title = $post->category->title; echo "<h3>$category_title</h3>"; } // whatever markup you want for the post echo "<p>$post->title</p>"; }3 points
-
2 points
-
2 points
-
Looks like we need to add this to the cheatsheet. The need for this came up for me a while back and I didn't know about this function, and just yesterday one of my coworkers asked me if there was a function for this!2 points
-
You should try to uninstall WireMailSMTP and try sending with native WireMail. This should work, as it uses the PHP mail() function. If WireMail works, and WireMailSMTP don't, it might be firewall restricted by your hosters settings. Native PHP mail function is controlled and allowed by your hoster, other (foreign) connections (other IPs or only Ports) maybe blocked by firewall settings of your hoster. (?)2 points
-
Your approach is slightly off – remember that the items in a Page Table field are actually pages. There's a few different ways you could do this, but here's how I've done it in the past, assuming the content blocks are children of the page: // Query normal pages $query = $sanitizer->text($input->get->query); $results = $pages->find('template!=content_block, title|body*="'.$query.'"'); // Query content blocks $content_blocks_query = [ 'template=content_block', // Template 'title|body*="'.$query.'"' // Fields ]; // Find parent pages of content blocks $content_block_results = new PageArray(); foreach ($pages->find( implode(', ', $content_blocks) ) as $p) { $content_block_results->add($p->parent); } // Combine results $results->import($content_block_results); // Render $results If you're talking about Page Table Extended's admin-side rendered HTML, it actually works independently of the normal templates. Take a look at the PageTable Render Layout Options, you can specify CSS and template files there.2 points
-
Hey @bernhard - I just PM'd you with a new version that should work as expect with ready.php and hooks inside it. If you can test for me, hopefully I can get a new version released. Thanks!2 points
-
We're developing the site for a Swiss architect, and meanwhile we prepared a very simple temporary page: http://gamisch.ch/ It's powered by PW, so I thought I should post anyway2 points
-
@Vayu Robins, to be honest I wouldn't be surprised if it wasn't. Repeaters, I believe, are somewhat supported, but Repeater Matrix is a lot more complex, at least as a concept. I'll look into this as soon as possible. @apeisa, I'll look into that image issue too. Unless that's really easy to fix, it might be time to release a 3.x branch of this module though. Could probably solve a bunch of things more cleanly now. API level tests still look good, so I'm thinking that this file issue might have something to do either with the "recent" UI updates, or perhaps the temp file thing..2 points
-
Hi all. For a while now been wondering how many would be interested in a backend and frontend shop catalogue built on top of PadLoper? I've previously spoken to @apeisa about this and his take is that there are no plans to develop PadLoper in this direction but he's happy to support such efforts. The gist of the backend shop catalogue is to provide one place (think ProcessModule) where you can manage your PadLoper products - add, edit, delete, track sales, etc without having to set up the underlying structure yourself. The frontend would be like a shop/webstore profile, a frontend cart basically, that's customisable. The shop would be 100% powered by PadLoper. This means that to use the 'shop catalogue' would require that PadLoper is installed. These are just loose ideas at the moment for a pro module. This might or might not see the light of day depending on feedback. Anyway, would love to hear thoughts, thanks.1 point
-
Is there an API method that gives the complete URL of the currently viewed page as it is known to PW? So not including any hashes or other URL changes that might have been made by Javascript (PW can't know about those) but basically $page->url + any url segments + any page numbers. Or does this have to be built manually from the other $input methods?1 point
-
First of all, I am somewhat new to processwire so forgive me if I don't explain things quite right... The actual requirement is more involved so I have attempted to simplify things down to a basic proof-of-concept starting point. For my current project we want to make an audit trail of all the changes made to any page that is using a given template. (say "company" as an example) The easy part was making the company template and its pages. So far I have made an audit template with a text field (let's call it "action") and a text area field. ("summary") Action is used to know what kind of action was being taken (created, saved, trashed, restore, etc) and summary holds a string version of the changes array as provided by the Page class. By default, the changes array only holds the names of the fields that have been changed and not the values. To get around this, we enabled advanced mode in the site config file ($config->advanced = true;) and set a custom class name ("PageWithHistory" - complete code is included below for reference) in the System tab of the company template. (viewing page settings confirms that it detects this change and was able to locate the class) Then we created a hook in the init file to intercept things as they are being saved. This works fine for changes to any of the company fields except one. When changes are made to the page reference field via the admin backend UI, the audit page is silently created and saved successfully and the company page gives a notice at the top of the screen that the company was saved successfully too. The issue that has shown up is that even though the company says it was saved successfully, the changes that were being made were not actually saved. There are no new entries in any of the log files so I don't think an error is occurring. If the last line of the hook (audit save) is commented out then the problem goes away and company is able to be saved once more. Over the last few days we have performed several troubleshooting steps to try to narrow down what the issue could be: Uninstalled all site modules Removed all other logic from init and ready files Moved hook and function from init to ready Switched which method is being hooked (from before saveReady to before save, for example) Renamed troublesome field Changed the which template the field is filtering on Changed from ASM select to checkboxes Tested adding audit trail to a different template and its page reference no longer actually saves One interesting twist is that I have a separate, local, installation of a brand new processwire site and this code works fine there. They are both running the same version (latest stable) and have the same template configurations. There is one big difference in their setups in that a starting profile was imported during the configuration of our dev site and my local site is a clean copy without that profile. I wouldn't think that would matter at this point as the modules it included have been uninstalled and the other items (such as fields & templates) are not involved. Does anyone have any thoughts on what the issue might be or how to go about troubleshooting this further? <?php namespace ProcessWire; $wire->addHookBefore('Pages::saveReady', 'actionManager'); function actionManager(HookEvent $event) { $page = $event->arguments('page'); $template = $page->template->name; // check what kind of page is being saved and if anything has actually changed if($template !== 'company' || !$page->isChanged()) { // don't record these changes return; } $audit = wire(new Page()); $audit->template = 'audit'; $audit->of(false); $audit->name = $page->name.'-'.microtime(); $audit->action = $event->method; $audit->parent = $event->pages->get('/audit/'); // this line is a simple way to convert the changes array to a string during testing - more will be needed prior to release $audit->summary = json_encode($page->getChanges(true), JSON_FORCE_OBJECT); $audit->save(); } <?php namespace ProcessWire; /** * Thin wrapper around the built-in class that enables tracking * changed values in addition to the default of just tracking the keys */ class PageWithHistory extends Page { /** * {@inheritDoc} * @see \ProcessWire\Page::__construct() */ public function __construct(Template $tpl = null) { parent::__construct($tpl); // turn on tracking changes - this is default, but do it anyway to be sure $this->setTrackChanges(Wire::trackChangesOn); // enable storing of values too $this->setTrackChanges(Wire::trackChangesValues); } }1 point
-
No ideas about the cause of this issue sorry. This may not be as bad as it sounds. Export/import fields via core feature Export/import templates via core feature Export/import modules and module settings via Module Toolkit Copy PHP files: templates, config, ready, etc Here's where it gets a bit experimental: Export/import pages via new core feature. @horst has had some success with it.1 point
-
see the docs and examples on that page: https://mpdf.github.io/reference/mpdf-functions/addpagebyarray.html $mpdf->AddPageByArray(array( 'orientation' => 'L', 'mgl' => '50', 'mgr' => '50', 'mgt' => '50', 'mgb' => '50', 'mgh' => '10', 'mgf' => '10', )); mgt = page margin from the top (where regular text starts, in the example it would start 50mm below the top) mgh = margin for the header (where the header text ends, in the example it would end 10mm from the top)1 point
-
Didn't know it was that simple, I really overcomplicated it with apache configurations and so. You made my day!1 point
-
Yep, it does not. Maybe because config.php is already included? I should check it Anyway, because of such issues I recently switched to using __DIR__, eg: require_once __DIR__ . '/./creds.php';1 point
-
You're right. require_once("creds.php"); // this works require_once("./creds.php"); // this doesn't No idea why.1 point
-
include_once "creds.php" and similar do work for me. Maybe is it something about your setup?1 point
-
the missing '}' was a incomplete copy/paste however i found another solution which works fine: $n = $article->view; $thumbs = $article->images->find("limit=$n");1 point
-
Did you set autoload to true? I was getting the same problem with a module and I read somewhere that it will only invoke the ready method if autoload's true.1 point
-
I ended up here because I searched for a solution. I would like to see such a page-edit-lock feature built-in the core as well. Go ahead and vote: https://github.com/processwire/processwire-requests/issues/231 point
-
Thanks Robin, The second one seems to be enough for what I need to do, and the simplest. I was overcomplicating the situation. I just had to add another loop to go through the post.category as it's a multiple page reference array.1 point
-
@zoaked and I are working on this project together. There is one other important quirk that I don't think was mentioned above, and that is that the only fields that are not being saved when the hook is in place are Page fields (FieldtypePage). It does not matter which Inputfield type (asmselect, checkboxes, etc.) the Page field is using. So, to very broadly summarize: Page 1 is saved Hook before Pages::saveReady() is fired New page (Page 2) is created and saved inside the hook (there is a template check to prevent recursion) Hook finishes and the save on Page 1 is allowed to complete Page 2 is created as expected, no problem. The unexpected result is that any changes made to any FieldtypePage fields on Page 1 are not saved. All other field types (text inputs, at least) save correctly. If the hook is removed, Page 1 saves everything correctly again. I have tested this on another one of our sites which uses the same site profile (our own custom profile we have created) and the same issue is present. I can also confirm zoaked's finding that the issue is not present on a fresh ProcessWire installation using the Minimal Site Profile. Could this be caused by some sort of database difference between a fresh install and an older profile which has undergone a few upgrades? We are on the verge of having to start from scratch on this project.1 point
-
I tried several options but for me adding all fields to the user template would be the way to go. I've experimented with different templates per role, but like @LostKobrakai mentioned this won't work when you have roles with overlapping functionality. Using several templates with Page fields is also an option I tried, but then the amount of templates increased. My simple solution: create per role a Fieldset and show and hide these fieldset based on InputfieldDependancies. So fieldset_role 1 will only show if role=1. This way you can visually hide fields that don't belong to certain roles. Yes, you have more fields, but at least you won't see them. And getting and setting data from the API is pretty straight-forward too. Although the template option won't create much overhead.1 point
-
Yeah doing that manually not not really a good thing if you expect so many users.1 point
-
Your selectors are not actually doing anything to filter the posts you want: If for example you have a category called "tech" and you want to find articles with that "category" field, you could do: $category = $pages->get("template=category, title=tech"); $posts = $pages->find("template=article-post, category=$category"); This also works with filtering multiple categories: $categories = $pages->find("template=category, title=tech|botany"); $posts = $pages->find("template=article-post, category=$categories"); Now, if you want to do your list with the headings and the posts underneath them, you'd have to loop through your categories and do the same thing. Hope it helps.1 point
-
Looks like you need to use $input->url(true) to get the query string with it. But maybe you already tried that?1 point
-
You're the man! I had no idea that setting exists. I was trying to modify the plugin directly and what not, but thanks to you (and of course Ryan) it is so much more convenient now.1 point
-
You mean this one? https://github.com/processwire/processwire/blob/master/wire/core/WireInput.php#L504 https://processwire.com/api/ref/input/http-url/ Does not seem to work. I get no query string. Not to mention the lack of urlSegmentsStr support, at least I cannot see it or looking at a completely wrong place... I dunno At least your snippet works fine. Thanks once more!1 point
-
@szabesz, I think this is covered by $input->url() and $input->httpUrl() now, which were introduced since I wrote my post above. There's a blog post about it somewhere but I can't find it at the moment.1 point
-
Weirdly it's working now... Or at least the image is loading the correct one. I have just cleared the default meta description from the MarkupSEO module settings and added directly to the homepage and then used the body as the smart description so it is used for open graph description and meta description for all other pages and that isn't showing the correct description yet when being posted but perhaps Facebook caches the results for a while? Either way you have been a BIG help and I can't thank you enough for taking the time to take a look with me! Thank you @videokid1 point
-
If possible, What domain where you sending from and to what domain where you sending to in your test emails? Are these accounts/SMTP Service associated with Your Hosting Provider, Gmail, Microsoft or any other third-party email provider?1 point
-
1 point
-
1 point
-
There are some links and also some code for creating repeaters and adding fields to it here: Shouldn't be anything special about doing it from a module. HTH.1 point
-
Yes, you are right. Regarding security, I was responding to the issue about root paths in general, but now I realise what you were really after is having the field's folder as a default. Anyway, this is resolved with having the third option I mentioned. Yes, the error messages are for the dev. Maybe I misunderstand; did you have a suggestion regarding error messages? You already have this option . OK, two options, one each for JS and CSS. So, rather than having one option "JavaScript and CSS included automatically", we have split that into two for JS and CSS respectively. The second options under JS and CSS "JavaScript/CSS file has identical name to this field". That will do what you are after, but with the errors of course, if there is no file present. I think that's a good reminder about missing files. Maybe we can add an option to suppress errors about missing files (..a leave me alone I know what am doing option .). That and the identical file name options should get you your wish (of coming back later to add JS/CSS). What do you think? On the contrary! I value your honest and helpful feedback! . Exactly .1 point
-
Make sure you are at least testing sending from one mail provider to another. Here are two links that may help you: http://kb.mailchimp.com/delivery/spam-filters/im-not-receiving-my-test-campaigns https://productforums.google.com/forum/#!topic/gmail/HB31aN_GR_81 point
-
@adrian do you think you can have a look why the hooks inside ready.php are not applied when executed from the tracy console? i had an issue again today... i wanted to test a simple property hook and got an error. i think that's quite a big issue because imho the panel code should just execute as if it were executed inside a template or module. and i guess testing hooks, functions, creating pages via the console etc. is a VERY common usecase for tracy-users... // get group of given fbrole $wire->addHookProperty('Page::group', function($event) { d('test'); $page = $event->object; if($page->template != 'fbrole') return; $event->return = $this->pages->get(1634); }); log (first from ready.php, then from init.php):1 point
-
@ryan thanks a lot! I had a little use case where I couldn't resist to use the new feature. It was only for pages with text fieldtypes. I used two little bootstrap scripts to export & import some pages. export.php import.php1 point
-
This is a tricky one, and the solution on the CMS side depends on how you want to do the frontend. You will not find a module that gets interactive 3d working on your frontend. PW modules mostly offer you ways of storing and retrieving info, but don't actually generate frontend widgets like slideshows and that kind of thing. First of all, the repeater is a go to module that you'll probably need somewhere along the road. Then just remember you can use file fields for storing 3d models or even JS that you load dynamically on the frontend, image fields for textures, and you have other field types for just about anything you can think of. For example, look at the nib selector on step 3 of your example. You can use a repeater to store each nib. Inside each repeater item you put in a title, an image file for the thumbnail, and a file field for the 3d model in whatever format you're going to use. Then you just have to figure out how to output that in your frontend so that the nib options can be managed from the CMS. Start by getting your frontend working statically. From there you'll see how to divide it into smaller chunks that can be served by PW and take it from there.1 point
-
You can make content blocks with Page Table or Page Table Extended, to display on any page. Create a Page Table field. Create templates for each of your content blocks, assigning the necessary fields (PHP files not necessary for these). Configure your Page Table field to use those content block templates. Assign Page Table field to your front-end template (template.php). In template.php, iterate over the Page Table field, and use PHP switch() to display different HTML and field data based on the content block name. If you want to get fancy, configure Page Table Extended to display rendered HTML on the admin side (Display Output Options).1 point
-
were you able to figure out your problem? i am having the same issue with the latest version of processwire1 point
-
I figured it out: While using Axios.post() one has to set the Header explicitly to: 'X-Requested-With': 'XMLHttpRequest' Just in case someone is facing the same Problem in the future: axios.post('/pathTo/script/', yourData, {headers: {'X-Requested-With': 'XMLHttpRequest'}}) Have a nice weekend.1 point
-
I agree, thats a bit tricky. There is a default setting in CKEditor which overrides the <i> tag with <em>. Luckily CKEditor is highly configurable, even in ProcessWire. If you don't want to disable ACF (Allowed Content Filtering) generally there is this specified solution: Create a config file: /site/modules/InputfieldCKEditor/config.js (if its not already there) with the following content to allow empty <i> tags as used for font-awesome icons CKEDITOR.config.protectedSource.push(/<i[a-z0-9\=\'\"_\- ]*><\/i>/g);1 point
-
$input->whitelist does not store values. It does just mark $input variables of the current request, so they can be appended to (pagination) links as ?my_data=xyz variables, which on the next request can be read again. If non of those links is clicked the values are gone. The most prominent use case is preserving any user filter values while going through pages of results. Having the values in the url also makes sure you can send that url to your peer and he or she can open it as well. Anything you don't want the user to see/modify you'd use the session.1 point