-
Posts
36 -
Joined
-
Last visited
Everything posted by applab
-
Showing downloaded html file within an iframe and getting 403 response
applab replied to Liam88's topic in Getting Started
@Matzn although the OP didn't specify, I'm assuming that the included content is coming from the same domain and therefore it's not a cross-origin problem, @Liam88 let us know if that's not the case. @Matzn's #5 suggestion is worth a try, you can use either <object> or <embed> instead of <iframe> but you can't populate it using a literal chunk of HTML, which is what I assume you're getting from `<?=$page->landing_page_html?>'`, you'll need to provide a URL that returns the content, so something like... <div> <embed type="text/html" src="<?= $pages->get('/landing-page/')->url ?>" width="600" height="400" /> </div> or <div> <object type="text/html" data="<?= $pages->get('/landing-page/')->url ?>" width="600" height="400"></object> </div> -
Showing downloaded html file within an iframe and getting 403 response
applab replied to Liam88's topic in Getting Started
In my experience 403's are usually the result of the hosts WAF (Web Application Firewall) being triggered (<iframe>'s are notorious for this). Contact your hosts support, give them the URL that's causing the 403 and ask them to check their WAF logs for a violation. It's not unlikely that they will add an exception for you, otherwise you'll need a re-think! -
Ok, so I decided to scratch my own itch on this one... I need to handle WebP's which include transparent regions so I've created a modified version of the @Robin S module (https://processwire.com/modules/webp-to-jpg/) but which allows you to choose between PNG or JPEG as the target format. https://gitlab.com/applab/pw-uploadwebp
-
Has thinking around this issue changed at all? Support for .webp as an upload format for images would be a game-changer for my current project (and has been requested by several previous clients).
-
Thank you very much, that has got me up & running :-) Thanks to your tip I've also realised that I can check 'Modules Loaded' in my Tracy debug bar if I encounter a similar situation again. Cheers, Martin.
-
Hi, I've installed the module FieldtypeComments and now I want to add comments via the API as shown here https://processwire.com/talk/topic/357-creating-comments-via-api/ But I'm getting a 'class not found' error on this line $c = new Comment(); I have no problem creating pages with `new Page();` but I'm unable to create a comment with `new Comment()` Can anyone point me in the right direction? Thanks, Martin.
-
Hi @bernhard, sorry for the delayed response but I'm flitting between 2 projects and have just come back to this. From looking at that Tracy source code and reading the Tracy docs it looks like the method used relies on the alt-template being in the main /site/templates/ folder and having a recognisable suffix. My goal is: 1) to keep dev templates outside of the main templates folder (eg. have /site/templates/ and /site/dev-templates/) 2) for /site/dev-templates/ not to require a full set of templates, just one or two that are being worked on, and to 'fallback' to the main templates folder if there is no tpl for the current request in dev-templates. My problem is that include files and assets are no longer in the same relative location if the alt-template is used when the dev-tpl is not in the same folder as the main tpl. TBH, it's not super-high priority but I think it would be useful both when collaborating or when modifying a live site so I will come back to it at some point.
-
Hi @monollonom Doing it this way still encounters the problem I had with my original method, ie. it finds the alternate template but require/include files aren't found as relative paths are now different. I'm not sure how I'm going to approach that, I will give it some thought over the weekend. BTW, because I have an extra level of folders I had to modify your code slightly to append a / after the username. $userTpl = str_replace("templates/", "templates-dev/" . $event->user->name . '/', $tpl->filename); Thanks for giving it some thought :-)
-
Thanks @monollonom, though as per @androbey's suggestion the conditional is not necessary if the username matches the folder name and can be used directly to construct a path. On a side note, I wasn't aware that fieldTemplates was a thing until I saw your post so I've learned something very useful :-)
-
This is exactly how I usually approach it. In this case though I was hoping to achieve a setup where each dev's folder does not need to contain a full set of template files, just the one or two they are working on, and for any template not found in the dev's folder it will fallback to the main template directory, ie. the same way Wordpress child themes work.
-
Thanks @androbey, I hadn't seen that post but I have used render() plenty of times, I might end up going that way. I've sort of got it working but I had to put my dev templates in the main template folder (with a different name) otherwise all my include paths are wrong. I was hoping to keep them separate.
-
Hi, I'm trying to change a template file at runtime based on the logged in users name. in addition to the /site/templates/ folder I have a /site/templates-dev/ folder, and under that is a folder for each developer. so, if I'm logged in as `timmy` and a file exists at `/site/templates-dev/timmy/article.php` then that file should be used, otherwise use `/site/templates/article.php`. in /site/ready.php I have $fp = $config->path('site') . 'templates-dev/' . $user->name . '/' . $page->template . '.php'; if(file_exists($fp)) { //echo "found tpl!"; $page->template->filename($fp); } If I uncomment the `echo` statement then I can see that it's finding the alternate template but if I view the page it's just blank (status 200, 'this request has no response data available'). Is anyone able to point me in the right direction please? Thanks, Martin.
-
module gets auto-installed if called from front-end?
applab replied to applab's topic in Module/Plugin Development
Thanks @kongondo, that is precisely the info I needed. Next time I'll RTFM a bit more before I post! -
module gets auto-installed if called from front-end?
applab replied to applab's topic in Module/Plugin Development
Hi @Zeka, Yes, I am using $modules->get("MyModule") in my front-end template. I was just surprised to see MyModule get installed as a result of that code rather than throwing an error, which is what I was expecting. I've achieved my original goal of preventing the install in that situation but I've realised that I still need to use isInstalled() in my front-end templates to avoid runtime errors so, thanks. -
Hi All, I'm making my first serious foray into module development and I've discovered some behaviour which I found surprising... If I uninstall my module from the backend but do not delete the file, then I refresh a front-end page that is using that module, I would expect to see some kind of error but what happens is the module gets automatically re-installed. I can mitigate this behaviour by wrapping my front-end code in: if(modules()->isInstalled('MyModule')) { ... } but that doesn't seem like the best approach if the module is used in multiple places. Is there something I can add to my modules install() method to prevent it getting auto-installed in this situation? Thanks.
-
What's a good forum software that can integrate with PW?
applab replied to OrganizedFellow's topic in Dev Talk
Has anyone implemented Flarum yet? I like the look of it but I'm concerned that it seems to be in perpetual beta. My top contender at the moment is Vanilla but it's use of Smarty is putting me off. -
Yes, that makes a lot of sense, thanks.
-
My method is this... The user will register using their email address and never actually know the username that's used to log them in behind the scenes. On registration the username will be derived from the email address and if there's a clash I'll simply add an incremental numeric suffix. When the user comes to login, the username is looked up from the email address (which is, of course, unique) and it doesn't matter if a suffix has been added or not, as long as it's the right username for the email address.
-
I had a feeling that the failure of $session->login($email, $pswd); might be related to email sanitization, but since my solution worked I gave up pondering. Before trying it I didn't expect it to work as I thought that without a logged-in admin session I wouldn't have permission to query admin pages. But your solution of using a sanitized email as the username and then sanitizing $input->post->email before calling $session->login() also makes a lot of sense. I'll be doing the registration form next so I might adopt that approach.
-
Ok, I've found a workaround by using the email to lookup the user name and then logging in with that instead. $e = $input->post->email; $p = $input->post->pswd; $u = $pages->get("email={$e}")->name; $session->login($u, $p);
-
I have configured ProcessLogin to use email instead of username (and enforced unique values for the email field). I can login to my admin just fine using an email address but I'm trying to create a front-end login form and it's failing. I've copied the example from https://processwire.com/api/ref/session/login/ and replaced the two params with hard-coded values known to work for backend login but I just get 'Sorry Bob'. Anyone have pointers on how to get this working from the front end?
-
Make dashboard plugin page the default admin page
applab replied to kriegar's topic in General Support
Doh!, you are indeed correct. How did I miss that in the 2 line readme! Thanks. -
Make dashboard plugin page the default admin page
applab replied to kriegar's topic in General Support
The last time I used this module was on Dev 3.0.149 and it worked fine (in conjunction with your AdminCustomPages module). I've just installed on Dev 3.0.155 and it seems to be having no effect. Any ideas? -
Hi Sierra, It looks like you haven't disabled the 'automatic prepend/append' option for your template. Navigate to Setup->Templates->YourTemplate Go to the 'Files' tab and tick the two 'Disable automatic...' boxes. Does that fix it?
-
I'm still at the shallow end of the learning curve with Docker so I can't answer from experience but, AIUI... Yes, build a Docker image locally for your app/site and it should run seamlessly on any Docker-supporting host, which includes things like AWS. Regarding performance, according to this IBM research paper "The general result is that Docker is nearly identical to Native performance and faster than KVM in every category" http://domino.research.ibm.com/library/cyberdig.nsf/papers/0929052195DD819C85257D2300681E7B/$File/rc25482.pdf Just found this, it looks like others have made more progress