Jump to content

Recommended Posts

57 minutes ago, Mike Rockett said:

@teppo - in regards to Jumplinks 2 and composer support: the module utilises several composer packages, which at present are kept in the vendor directory of the module, part of source control. Just to be 100% sure, if I were to drop this from source control, this would force users to install via composer? If so, I'd need to leave it in there, unless you know of another way 🙂

45 minutes ago, Mike Rockett said:

@wbmnfktr - Hence why I'm needing some more info – not sure if any additional composer support has been added. Would be great if I could trigger an install during module install from the UI. 🙂

Sorry, I've got nothing for this. At this point my suggestion would be to keep those packages in the repository. It's the only way that works seamlessly with the module installer in Admin, and I believe it makes more sense for your module than any of the alternatives I can think of. Anything else would reduce your potential user base significantly.

I've gone the other way with some of my projects, but those have mainly been site profiles, so the context is quite different. While I agree that a native Composer installation integration could be nice, we're not quite there yet — at this point requiring Composer may make sense for hard-core developer-oriented projects, not much else.

57 minutes ago, Mike Rockett said:

On the topic of dependencies, I'm feeling inclined to push the minimum PHP version to the one that still has active security support, which at this point is PHP 7.1.

Go for it! I've been putting out PHP 7.1+ content for a while now, and so far no complaints.

It's perhaps worth noting that PHP 7.1 is well on its way to being obsolete as well: it's already past the active support phase, and in just over two months it will stop receiving security updates. While certain organisations may backport security fixes for 7.1 for a while after that, officially its really close to the end of its lifespan. Folks should be already using (or at the very least actively updating to) 7.2 – or preferably 7.3 🙂

56 minutes ago, Mike Rockett said:

I'd also like to drop support for ProcessWire 2.8. Any objections?

Again: go for it 🙂

I don't think that this will affect a particularly large portion of users (last time I polled this was in 2017, but even back then ~55% of those responding were already on 3.0), 2.8 itself hasn't been updated for almost three years now, and users of legacy versions can always keep using one of the solutions that work for said legacy setups.

Share this post


Link to post
Share on other sites
5 minutes ago, teppo said:

Sorry, I've got nothing for this. At this point my suggestion would be to keep those packages in the repository. It's the only way that works seamlessly with the module installer in Admin, and I believe it makes more sense for your module than any of the alternatives I can think of. Anything else would reduce your potential user base significantly.

Ah ok, thanks for the clarification there. Guess the optimist in me was hanging around 🙂

6 minutes ago, teppo said:

Go for it! I've been putting out PHP 7.1+ content for a while now, and so far no complaints.

Good to know - thanks!

Share this post


Link to post
Share on other sites
On 9/15/2019 at 12:07 PM, Mike Rockett said:

These columns are sorted in 1.5.56. However, instead of text, I've gone with varchar(512), which should be more than long enough. 🙂

Thanks for this Mike. 

Not sure if 512 is long enough. There isn't any limitations for user agent length (other than server limit for headers) and if request_uri means uri that user were redirected - then few pointers for uri lengths:

Quote

The HTTP protocol does not place any a priori limit on the length of a URI

and 

Quote

Extremely long URLs are usually a mistake. URLs over 2,000 characters will not work in the most popular web browsers. 

https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers

So if you want to limit these at the database level, then you should clip values also to that length.

Share this post


Link to post
Share on other sites

Hello, I'm having a really strange issue with this plugin. I using the latest version of PW and all modules. I have a blog (using ProcessBlog & MarkupBlog) and removed a bunch of old posts, I wanted to redirect them to the main blog page (domain.com/blog/). For whatever reason, if I try to register a new jumplink and it has "blog/" in the source (domain.com/blog/posts/some-post/), the redirect doesn't work. I thought maybe I had a problem with one of the existing blog post redirects, so I removed all jumplinks with "blog/" in them and it's still happening. I've tried disabling my other modules, installed Tracy Debugger (no issues), uninstalled Jumplinks and re-installed....no luck. I turned on debug mode in Jumplinks and if I open the source (original) URL in a browser, the debug screen isn't shown. If I register a new jumplink and don't have "blog/" in the source, everything works fine. Even stranger, if I try to visit one of the source URLs with "blog/" in it, the content for the intended page is displayed, but the address bar still shows the source (original) url. I've been pulling my hair out all day and have run out of ideas, please help! 😃

Share this post


Link to post
Share on other sites

Are those domain.test/blog/post/ URLs based on URL segments in the template?
If so... that might be the reason why JumpLinks doesn't kick in.

It's not a solution but maybe another thing you could look into.

Share this post


Link to post
Share on other sites

Ok. I don't know if there is anything modified in your site or a difference in our installed modules so this might not work but I just installed ProcessBlog & MarkupBlog and of course the latest Jumplinks module.

I unpublished the example post, opened it in a private window where a 404 showed up.
I looked into the Jumplinks 404 monitor and found the request.
I opened that entry, created a new jumplink from it and visited the URL in a private window again and... it worked.

ProcessWire 3.0.123 the other modules straight from modules.processwire.com.

2019-10-10-230022_812x599_scrot.png.f40dc5d362b40a4e8a1874da9df3a352.png

Share this post


Link to post
Share on other sites
4 minutes ago, wbmnfktr said:

I opened that entry, created a new jumplink from it and visited the URL in a private window again and... it worked.

Yeah, it's weird... I've been using this module for a couple years and never had a problem. The redirects do still work on any source url that don't have "blog/" in them. I'm stumped. Here are the modules I've added in case it helps, all are the latest versions.

AdminOnSteroids
AutoSmush
BlogPublishDate
FieldtypeStarRating
FormBuilder
GoogleClientAPI
InputfieldFormBuilderFile
InputfieldStarRating
MarkupBlog
MarkupSimpleNavigation
MarkupSitemapXML
ProCache
ProcessBlog
ProcessDatabaseBackups
ProcessFormBuilder
ProcessJumplinks
ProcessProCache
ProcessTracyAdminer
ProcessWireUpgrade
ProcessWireUpgradeCheck
TracyDebugger
WireMailGmail

Share this post


Link to post
Share on other sites

@Ben Sayers This could indicate that something's wrong with your blog setup. To clarify, are you deleting posts or un-publishing them? Either way, whatever is going on here is preventing the 404 event from kicking in, which means Jumplinks has nothing to do. When it comes to common patterns like this (ie, "blog/*"), the only things that come to mind are urlSegments and custom htaccess directives, both of which I suspect are not the case for you. Worst case, I would try reproducing on a fresh install.

On a side note: I don't know ProCache very well, but could it possibly be that?

Share this post


Link to post
Share on other sites

@apeisa I think I'll take the trimming option here, for now. I have been doing incremental work on JL2 in my very short-lived spare-time, and will be using a text column for referrers in the hits table. I'm deciding whether or not the 404 monitor should still be a separate module like I'd originally intended - still makes more sense to me, but either way, the same column type will be used there.

Share this post


Link to post
Share on other sites
6 hours ago, Mike Rockett said:

On a side note: I don't know ProCache very well, but could it possibly be that?

From my experience: Jumplinks and ProCache play really nice together. 

  • Like 1

Share this post


Link to post
Share on other sites
On 10/11/2019 at 12:01 AM, Mike Rockett said:

To clarify, are you deleting posts or un-publishing them? When it comes to common patterns like this (ie, "blog/*"), the only things that come to mind are urlSegments and custom htaccess directives

I deleted the posts. I do use URL segments for the AMP versions of my pages but I'm not creating any jumplinks for those (yet). The only htaccess directives I added are for alternate domain names to redirect them to our primary domain. Like this:

RewriteCond %{HTTP_HOST} ^secondarydomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.secondarydomain.com$
RewriteRule (.*)$ https://www.primarydomain.com/$1 [R=301,L]

 

Share this post


Link to post
Share on other sites

Hi everyone,

I haven't really used this module much before, but just came across something that I thought should work, but it doesn't seem to.

This works:

image.png.cd1e601e66d48a4d84d428134a11a7c7.png

But this doesn't:

image.png.b6ed0a19fcb903177ea12609bedfa0cb.png

which of course means that if someone changes the name of the "buy-now" to something else, not only do I need to add a new jumplink from "buy-now" to the new name, but I also need to remember to change the destination for the initial linking from "/subscribe" to the path of the renamed page. Is there any reason the "page:1495" format can't also work when using wildcards?

Just in case it's not clear, {all} represents a PW url segment.

Thanks for any thoughts.

OT, but I was actually a little surprised that the core PagePathHistory module doesn't try to handle paths with urlsegments - I know it's not simple, but I thought it could try to strip back a segment at a time to try to find the actual page and redirect to the stored ID.

Share this post


Link to post
Share on other sites

@Ben Sayers, if you're still having problems and just need a solution to get the redirects working you could hook ProcessPageView::pageNotFound in /site/init.php

$wire->addHookBefore('ProcessPageView::pageNotFound', function(HookEvent $event) {
	$url = $event->arguments(1);
	// The old URLs you want to redirect from (relative to site root)
	$redirects = [
		'/blog/foo/',
		'/blog/bar/',
	];
	if(in_array($url, $redirects)) {
		// Get the blog landing page however suits
		$blog_page = $this->wire('pages')->get('template=blog');
		// Redirect to blog landing page
		$this->wire('session')->redirect($blog_page->url);
	}
});

 

Share this post


Link to post
Share on other sites
7 hours ago, adrian said:

OT, but I was actually a little surprised that the core PagePathHistory module doesn't try to handle paths with urlsegments - I know it's not simple, but I thought it could try to strip back a segment at a time to try to find the actual page and redirect to the stored ID.

Equally OT, but it sounds like this could result in unwanted consequences: PagePathHistory hooks into ProcessPageView::pageNotFound, so initially it only knows that a Page is missing. If it doesn't have a record for that exact URL, the most straightforward approach for supporting URL segments (as you've suggested) would mean that it needs to recurse through the path and see if it can find a record for a partial match for a Page that has URL segments enabled (which is getting somewhat complex, and creates a bit of overhead), and – since ProcessWire can't really know for sure which segments are available, let alone were available in the past – it would probably just have to assume that anything goes.

In addition to the overhead and general unreliability, it also sounds like this could create redirects for URLs that should just throw a 404, and we'd also have some new questions: is it enough to check if the target page currently has URL segments active, or should we assume that this may have changed as well? What about the redirect – is it enough (i.e. helpful) to redirect to the parent page, or should it attempt to redirect to an URL segment on that page? If we do that and it fails, what next?

All in all I can see a number of potential gotchas here, so not supporting URL segments seems like a reasonable decision. They are "virtual paths", and PagePathHistory is for real paths 🙂

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for your thoughts @teppo - I agree it's not a simple problem to solve and that there are some gotchas for sure. However I feel like if some assumptions are made, it could be made to be functional.

Firstly, if only supported first level pages (those directly under home), we could simply strip off everything after the second forward slash and assume those are urlsegments and simply find the page that matches the ID of the page whose name was changed and then re-append all those segments as they were in the original URL. I know this wouldn't solve the problem for all setups but I bet it would handle most. I think this discussion should be continued here: https://github.com/processwire/processwire-requests/issues/338

  • Like 1

Share this post


Link to post
Share on other sites
On 10/22/2019 at 6:18 PM, Robin S said:

@Ben Sayers, if you're still having problems and just need a solution to get the redirects working you could hook ProcessPageView::pageNotFound in /site/init.php


$wire->addHookBefore('ProcessPageView::pageNotFound', function(HookEvent $event) {
	$url = $event->arguments(1);
	// The old URLs you want to redirect from (relative to site root)
	$redirects = [
		'/blog/foo/',
		'/blog/bar/',
	];
	if(in_array($url, $redirects)) {
		// Get the blog landing page however suits
		$blog_page = $this->wire('pages')->get('template=blog');
		// Redirect to blog landing page
		$this->wire('session')->redirect($blog_page->url);
	}
});

 

Hi Robin, thanks for the advice! I tried adding this to init.php (using my real posts URLs of course) but I get the same result as when I try to add them using Jumplinks. If I load one of the URLs in my browser, I see the blog landing page but the URL is still the old one (/blog/post-title/ instead of just /blog/. If I try to redirect a page using this code that isn't a blog post, it doesn't work, I just get a 404. 

Share this post


Link to post
Share on other sites
7 hours ago, Ben Sayers said:

If I load one of the URLs in my browser, I see the blog landing page but the URL is still the old one (/blog/post-title/ instead of just /blog/.

Sounds like something is interfering before ProcessPageView::pageNotFound can execute. You can check by using Tracy Debugger to dump $url inside the hook and see if the hook is firing or not. If not then it might be caused be something in .htaccess or in Jumplinks. To check you could copy the site to your local machine, replace .htaccess with a clean copy and uninstall Jumplinks - whether it's worth the trouble depends on how important it is to you to get those redirects working.

Share this post


Link to post
Share on other sites
On 10/24/2019 at 6:07 PM, Robin S said:

You can check by using Tracy Debugger to dump $url inside the hook and see if the hook is firing or not.

Hi Robin, I'm not sure how to do that... Can you elaborate? I enabled Tracy Debugger but don't see any errors when I visit one of the blog post URLs that should be redirected. Thanks for your help!

Share this post


Link to post
Share on other sites

@Ben Sayers, you can use bd() to dump the $url variable in the hook.

$wire->addHookBefore('ProcessPageView::pageNotFound', function(HookEvent $event) {
	$url = $event->arguments(1);
	// Dump $url to the Tracy debug bar
	bd($url, 'url');
	// The old URLs you want to redirect from (relative to site root)
	$redirects = [
		'/blog/foo/',
		'/blog/bar/',
	];
	if(in_array($url, $redirects)) {
		// Get the blog landing page however suits
		$blog_page = $this->wire('pages')->get('template=blog');
		// Redirect to blog landing page
		$this->wire('session')->redirect($blog_page->url);
	}
});

When you visit a URL that does not match any page then you'll see the $url variable dumped via the Tracy debug bar. Tracy docs are here: https://adrianbj.github.io/TracyDebugger/#/debug-methods?id=bardump

2019-10-26_114634.png.e62d056ac70a8eee91048a7ea7d99ff1.png

Enter some random letters in the URL to confirm that the hook is firing and you can see the dump. Then try one of your old blog post URLs. If you don't see any dump then the hook is not firing, in this case because ProcessPageView::pageNotFound() is not executing. In which case you have something interfering before PW can attempt to render the page requested in the URL - so probably due to an .htaccess rewrite or something caused by Jumplinks (or another module or hook if you have anything else that affects URLs).

Share this post


Link to post
Share on other sites

@adrian Page identifiers were never intended to be used as part of a destination. These identifiers use the full, absolute URL of the page being identified. Perhaps destination selectors could come in handy here? Haven't ever tried it this way before, but I imagine redirecting subscribe/{all} to [[1495]]{all} (or [[1495]]/{all}} if trailing slashes are turned off) would work. Anything inside the square braces is passed to pages->get and replaced with page->url, which is why I believe this will work.

  • Like 1

Share this post


Link to post
Share on other sites
22 hours ago, Robin S said:

@Ben Sayers, you can use bd() to dump the $url variable in the hook.

When you visit a URL that does not match any page then you'll see the $url variable dumped via the Tracy debug bar. Tracy docs are here: https://adrianbj.github.io/TracyDebugger/#/debug-methods?id=bardump

Enter some random letters in the URL to confirm that the hook is firing and you can see the dump. Then try one of your old blog post URLs. If you don't see any dump then the hook is not firing, in this case because ProcessPageView::pageNotFound() is not executing. In which case you have something interfering before PW can attempt to render the page requested in the URL - so probably due to an .htaccess rewrite or something caused by Jumplinks (or another module or hook if you have anything else that affects URLs).

Hi Robin, I tried this but I don't see anything being dumped via the Tracy Debug bar. Even when using random letters,  I see my 404 page but nothing in the dump. If I load one of the blog posts that should be redirecting, I see the the Blog landing page content but it still shows the old URL (the same thing that happens when I try to use Jumplinks to redirect blog posts). Your code is the only thing I have in my init.php file except for my _func.php include. The only edits to my .htaccess file are those required by ProCache (gzip & manual directives). I do use url segments for the amp versions of my pages but I haven't created an amp version of my blog pages yet so I'm stumped on what can be causing this. I'm using the latest versions of PW and all modules.

Share this post


Link to post
Share on other sites
18 minutes ago, Ben Sayers said:

This is the only thing I have in my init.php file except for my _func.php include.

I think you might be working with the wrong init.php - you'll see in my earlier post that the hook needs to go in /site/init.php. Along with /site/ready.php this is one of the places that hook code is commonly added to. You can create either/both of these files if they don't exist. More info in this blog post: https://processwire.com/blog/posts/processwire-2.6.7-core-updates-and-more/#new-core-files-for-site-hooks

Turn off ProCache while you are investigating the issue to make sure it isn't contributing to the problem.

 

Share this post


Link to post
Share on other sites

@Ben Sayers

I'm by no means an expert on hooks, but I usually put hooks in ready.php, not init.php. Maybe that's the reason why your hook is not even firing.

https://processwire.com/docs/modules/hooks/#where-should-i-define-my-hook

Quote

The ready.php file is called when the API is ready, but before page rendering has begun. While the init.php file is called during ProcessWire initialization (before the API is fully ready).

 

Share this post


Link to post
Share on other sites

Sorry Robin, you were right, I was working in /site/templates/init.php so I removed the code from that file and placed it in a new file at /site/init.php but I get the same result (nothing happens). How does /site/init.php get called? I don't have a /site/ready.php file. I disabled ProCache when this all started, it doesn't have any effect when it's on though (it's currently off). Really appreciate your help, I don't understand why the Jumplinks work with any page that doesn't contain "blog/".

Edit: I had the file named incorrectly (/site/_init.php) so I removed the underscore in the name and now I can see the dump is working but only for URLs that don't have "blog/" in them and I'm not redirected to the blog landing page, I get a 404. If I try a link with "blog/" in it, I see the blog landing page but the URL is still the old one instead of domain.com/blog/.

Edited by Ben Sayers
Small update regarding /site/init.php

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By Robin S
      A module created in response to the topic here:
      Page List Select Multiple Quickly
      Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page.
      The screencast says it all:

       
      https://github.com/Toutouwai/PageListSelectMultipleQuickly
      https://modules.processwire.com/modules/page-list-select-multiple-quickly/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImagePicker. It provides a configurable input field for choosing any type of image from a predefined folder.
      The need for it came up because a client had a custom SVG icon set and I wanted the editors to be able to choose an icon in the page editor.
      It can also be used to offer a choice of images that are used site-wide without having to upload them to individual pages.
      There are no image manipulation methods like with the native PW image field.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImagePicker
      Kudos to @Martijn Geerts. I used his module FieldTypeSelectFile as a base to build upon.
      Here's how the input field looks like in the page editor:

      Hope it can be of use to someone.
      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Eventually this will go in the module directory soon, too.
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://github.com/BernhardBaumrock/RockPDF
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
    • By ukyo
      FieldtypeFontIconPicker
      Supported Icon Libraries
      FontAwesome 4.7.0 Uikit 3.0.34 IonicIcons 2.0.1 Cahangelog
      NOTE: Module store data without prefix, you need to add "prefix" when you want to show your icon on front-end, because some of front-end frameworks using font-awesome with different "prefix".
      Module will search site/modules/**/configs/IconPicker.*.php and site/templates/IconPicker.*.php paths for FieldtypeFontIconPicker config files.
      All config files need to return a PHP ARRAY like examples.
      Example config file : create your own icon set.
      File location is site/configs/IconPicker.example.php
      <?php namespace ProcessWire; /** * IconPicker : Custom Icons */ return [ "name" => "my-custom-icons", "title" => "My Custom Icon Set", "version" => "1.0.0", "styles" => array( wire("config")->urls->templates . "dist/css/my-custom-icons.css" ), "scripts" => array( wire("config")->urls->templates . "dist/js/my-custom-icons.js" ), "categorized" => true, "attributes" => array(), "icons" => array( "brand-icons" => array( "title" => "Brand Icons", "icons" => array( "google", "facebook", "twitter", "instagram" ) ), "flag-icons" => array( "title" => "Flag Icons", "icons" => array( "tr", "gb", "us", "it", "de", "nl", "fr" ) ) ) ]; Example config file : use existing and extend it.
      File location is site/configs/IconPicker.altivebir.php
      <?php namespace ProcessWire; /** * IconPicker : Existing & Extend */ $resource = include wire("config")->paths->siteModules . "FieldtypeFontIconPicker/configs/IconPicker.uikit.php"; $url = wire("config")->urls->templates . "dist"; $resource["scripts"] = array_merge($resource["scripts"], ["{$url}/js/Altivebir.Icon.min.js"]); $resource["icons"]["flag-icons"] = [ "title" => "Flag Icons", "icons" => array("tr", "en", "fr", "us", "it", "de") ]; $resource["icons"]["brand-icons"]["icons"] = array_merge($resource["icons"]["brand-icons"]["icons"], array( "altivebir" )); return $resource; After you add your custom config file, you will see your config file on library select box. Library Title (Location Folder Name).

      If your library categorized and if you have categorized icons set like uikit and fontawesome libraries, you will have category limitation options per icon field or leave it empty for allow all categories (default).

      Example : output
      if ($icon = $page->get("iconField")) { echo "<i class='prefix-{$icon}' />"; } MarkupFontIconPicker Usage
      // MarkupFontIconPicker::render(YourIconField=string, Options=array) echo MarkupFontIconPicker::render($page->YourIconField, [ 'prefix' => 'uk-icon-', // Icon class prefix, if you have different prefix, default is : "fa fa-" 'tag' => 'span', // Icon tag default is : "i" 'class' => 'fa-lg', // If you have extra cutom classes, for example : icons sizes, Array or Sting value 'style' => 'your custom styles if you have' // Array or String Value ]); Theme support

      Search support

      Category support

       
×
×
  • Create New...