Jump to content
ryan

PW 3.0.106 – Core updates

Recommended Posts

Several core updates this week including a new way to perform $pages->find() searches by using Field tags, a new Field tag manager, new methods added to our $input API variable, new Inputfield traversal methods, and more…

https://processwire.com/blog/posts/pw-3.0.106/

  • Like 10

Share this post


Link to post
Share on other sites

Thanks for the new features Ryan!

Just one question though regarding the new $pages->find tag search feature: what happens if there is a field and a tag having the same name (ie name collision)? Does field name take precedence?

Edited by szabesz
typo
  • Like 1

Share this post


Link to post
Share on other sites

That's right, field names have precedence, and it also warns you if you try to create a tag that collides with a field.

  • Like 4

Share this post


Link to post
Share on other sites
6 minutes ago, ryan said:

and it also warns you if you try to create a tag that collides with a field.

Great! There might be cases when updating a system with "field name == tag name". Is there any warning implemented fur such a scenario?

EDIT: or tags/fields are created via the API rather than the admin.

Edited by szabesz
see EDIT

Share this post


Link to post
Share on other sites

Thank you very much for these new and - as always - useful features.

I have a question regarding the update of pagination module (MarkupPagerNav) to automatically populate $config->pagerHeadTags.

@ryan you explained: To use, simply populate them in your document <head> after pagination has been rendered [...]

So, do you mean i have to insert some code within the <head> tags in order to generate <link rel='next'> and <link rel='prev'> tags? - If so: How exactly would i accomplish this task? I've heard the first time of $config->pagerHeadTags, neither found documentation in https://processwire.com/api/ref/config/ nor in https://processwire.com/api/ref/markup-pager-nav/ . But then again i think i wouldn't have to do anything manually if the modules populates $config->pagerHeadTags automatically?

Surely i misunderstood something basic here. Thanks in advance for some enlightenment.

Share this post


Link to post
Share on other sites

@Lenz https://github.com/processwire/processwire/blob/643c9d3a87ddd8d579c4879c2382a9170466344b/wire/modules/Markup/MarkupPagerNav/MarkupPagerNav.module#L675

$_pages = $pages->find('id>1, limit=10');
foreach ($_pages as $p) {
    echo "{$p->title}<br>";
}

echo '<hr>$config->pagerHeadTags: ', \htmlspecialchars($config->pagerHeadTags), '<br>';
echo $_pages->renderPager();
echo '$config->pagerHeadTags: ', \htmlspecialchars($config->pagerHeadTags), '<br>';

 

Share this post


Link to post
Share on other sites

Hi @ryan,

The new field tag features are cool, thanks!

It's not quite the same, but in some ways being able to use a different name (tag) to refer to a field in a selector is similar to a request I raised a while ago about an idea for field aliases. So for example if I have a field with a generic name like text_1, when it is in my employee template I can use it in my template file and selectors as first_name. That would help a lot with code readability and encourage more efficient field re-use. Could the new field tag features be leveraged in some way to add support for field aliases? Probably as a separate thing to tags, but perhaps building on some of the same code you added this week? 

  • Like 3

Share this post


Link to post
Share on other sites

Lenz: If you just output that $config var in your <head>...</head> it will take care of it for you. i.e.

<?=$config->pagerHeadTags?> 

It is just a shorter version of doing this (which you can do in any PW 3.x version): 

<?php
if($config->urls->next) echo "<link rel='next' href='{$config->urls->next}' />";
if($config->urls->prev) echo "<link rel='prev' href='{$config->urls->prev}' />";
?>

 

  • Like 1

Share this post


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

[...] Could the new field tag features be leveraged in some way to add support for field aliases? [...]

That'd be great! +1

  • Like 1

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.

×
×
  • Create New...