Jump to content

PW 3.0.43 core updates


ryan
 Share

Recommended Posts

Another week, another set of useful updates. :)

It would be good if there was a URL option to return the complete URL of the current page, including URL segments and page numbers. Earlier in the year I was looking for such a feature and had to do this:

$full_url = $page->url;
if($input->urlSegmentsStr) {
    $full_url .= $input->urlSegmentsStr . "/";
}
if($input->pageNum > 1) {
    $full_url .= $config->pageNumUrlPrefix . $input->pageNum;
}

 

Regarding the /*NoCompile*/ comment, it seems it doesn't work if the include statement uses a relative path without any dot syntax (which may not be best practice but is still valid). So for an included file in the same directory...

include "test_include.php" /*NoCompile*/;

...the included file is still compiled.

 

Link to comment
Share on other sites

5 hours ago, Robin S said:

Regarding the /*NoCompile*/ comment, it seems it doesn't work if the include statement uses a relative path without any dot syntax (which may not be best practice but is still valid). So for an included file in the same directory...


include "test_include.php" /*NoCompile*/;

...the included file is still compiled.

Are you 100% sure that the file is not just being copied to the cache directory without being compiled? As far as I know, this is by design.

Link to comment
Share on other sites

3 minutes ago, Mike Rockett said:

Are you 100% sure that the file is not just being copied to the cache directory without being compiled?

I am testing using:

FileCompiler=?

With dot syntax the /*NoCompile*/ comment works, but not without.

include "./test_include.php" /*NoCompile*/; // included file is not compiled
include "test_include.php" /*NoCompile*/; // included file is compiled

 

Link to comment
Share on other sites

5 hours ago, Juergen said:

Hello Ryan,

after updating from 3.042 to 3.0.43 dev I always get the following error if I want to load my page tree:

Screenshot_1.jpg

Maybe you can take a look at the Page.php.

Best regards

Hello @Juergen I had the same problem as you, but after update from 3.0.41 to 3.0.42

I have found that this error is caused by any code like: 

if($page->image_field) 

where in field only one image. 

I really not sure what helped to me, but for the first time I used Updater module for update, but then I done update manually and this error disappear, 

That's why I didn't open issue for it.

 

Link to comment
Share on other sites

Quote

It would be good if there was a URL option to return the complete URL of the current page, including URL segments and page numbers.

This is the $input->url() method. 

Quote

 

Regarding the /*NoCompile*/ comment, it seems it doesn't work if the include statement uses a relative path without any dot syntax (which may not be best practice but is still valid). So for an included file in the same directory...

include "test_include.php" /*NoCompile*/;

 

Without a "./" before it, PHP could feasibly load that file from anywhere in the php include path, and this is why we always say not to do that in your PW templates (unless you really need to have it load from a undefined location). I've not coded FileCompiler to try and track down files from the include path, because FileCompiler can only work with files in /site/. So it does require that a directory be part of the include, even if it's the current "./" directory. It may still work in some cases without it, but I wouldn't recommend it. 

Also, per the blog post, the /*NoCompile*/ has to be within parenthesis. Or to state it differently, it means you have to use include/require/etc. as a function call like include("./test_include.php" /*NoCompile*/); 

Quote

after updating from 3.042 to 3.0.43 dev I always get the following error if I want to load my page tree:

Thanks, yes it looks like I had an error there that could be triggered in certain cases. I've pushed a fix that is now on the dev branch.

  • Like 4
Link to comment
Share on other sites

8 hours ago, ryan said:

This is the $input->url() method. 

Perfect, don't know how I missed that. :)

8 hours ago, ryan said:

Also, per the blog post, the /*NoCompile*/ has to be within parenthesis. Or to state it differently, it means you have to use include/require/etc. as a function call like include("./test_include.php" /*NoCompile*/);

Is this because the parentheses are needed as a kind of delimiter when looking for the /*NoCompile*/ comment? I often see parentheses used with include but thought that was a personal preference of the coder - like, you could use parentheses with echo if you wanted but it's not necessary. The PHP docs say that parentheses are not needed with include/include_once/require/require_once, and they are not used in the code examples there.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...