Jump to content
kcnpxcp

Dynamic Tag URLs

Recommended Posts

Hi there,

I am new on using PW. So this is my first Post. In order of that, i want to say Hello to everybody.

I used PW, to create a Blog with Tagging Function. I used the Page Field Type to create a new Page from a new Tag, defined in a Blog Article.

My Problem is, when I create a New Tag for example "Title A" the Tag and a Page is correctly been created. But the URL of the new Tag Page is a fallback solution like 2014-12-16....

How it is possible to define a custom URL from the Title, as PW does, when I "manually" create a new Page. The easiest Way is the Favorite. I thought I can hook up the Page-Save-Event to Auto-Create a URL, but that would be not that easy. Also I have to fill 2 Fields because its a multilanguage Site.

Can anybody help?

Greetings from Germany

Share this post


Link to post
Share on other sites

Welcome to PW!

Perhaps you are looking for this? This is in the template family tab. You can define a children name format for the parent template of your tag-template.

stZkQGt.png

  • Like 1

Share this post


Link to post
Share on other sites

@kcnpxcp
Welcome to the forum. If you create a new page from the page field you have to change the name later under the tab field settings. If you have only a few tags its easier to create them manually and add them to your fieldtype page.

You can also create pages from API within a template:

$pages->add($template, $parent, $name);

In this case title will betaken from name. Does this help?

@owzim
This option doesn't work by creating a new page via fieldtype page. Furthermore Name format for children is still under development and doesn't work properly. Look here:
https://processwire.com/talk/topic/8551-custom-urls-for-pages/?p=82742

Share this post


Link to post
Share on other sites

Hi,

thank you for your help. This straight answer saves a lot of "Frickelarbeit". In this way I will use the option creating Tags manually. This keeps also a better overview of which tags are actually created.

  • Like 1

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By humanafterall
      Hi,
      I have a URL field that will sometimes have relative/local URLs on a multilingual site, for example /contact/ 

      However the URL field does not seem to pick up when I'm on another language, for example /fr/ so I'm taken to the default language page for /contact/ rather than /fr/contact/
      Is there a way to make the URL fields play well with a multi-language site?
      Thanks!
       
    • By Robin S
      A new module that hasn't had a lot of testing yet. Please do your own testing before deploying on any production website.
      Custom Paths
      Allows any page to have a custom path/URL.
      Note: Custom Paths is incompatible with the core LanguageSupportPageNames module. I have no experience working with LanguageSupportPageNames or multi-language sites in general so I'm not in a position to work out if a fix is possible. If anyone with multi-language experience can contribute a fix it would be much appreciated!
      Screenshot

      Usage
      The module creates a field named custom_path on install. Add the custom_path field to the template of any page you want to set a custom path for. Whatever path is entered into this field determines the path and URL of the page ($page->path and $page->url). Page numbers and URL segments are supported if these are enabled for the template, and previous custom paths are managed by PagePathHistory if that module is installed.
      The custom_path field appears on the Settings tab in Page Edit by default but there is an option in the module configuration to disable this if you want to position the field among the other template fields.
      If the custom_path field is populated for a page it should be a path that is relative to the site root and that starts with a forward slash. The module prevents the same custom path being set for more than one page.
      The custom_path value takes precedence over any ProcessWire path. You can even override the Home page by setting a custom path of "/" for a page.
      It is highly recommended to set access controls on the custom_path field so that only privileged roles can edit it: superuser-only is recommended.
      It is up to the user to set and maintain suitable custom paths for any pages where the module is in use. Make sure your custom paths are compatible with ProcessWire's $config and .htaccess settings, and if you are basing the custom path on the names of parent pages you will probably want to have a strategy for updating custom paths if parent pages are renamed or moved.
      Example hooks to Pages::saveReady
      You might want to use a Pages::saveReady hook to automatically set the custom path for some pages. Below are a couple of examples.
      1. In this example the start of the custom path is fixed but the end of the path will update dynamically according to the name of the page:
      $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'my_template') { $page->custom_path = "/some-custom/path-segments/$page->name/"; } }); 2. The Custom Paths module adds a new Page::realPath method/property that can be used to get the "real" ProcessWire path to a page that might have a custom path set. In this example the custom path for news items is derived from the real ProcessWire path but a parent named "news-items" is removed:
      $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'news_item') { $page->custom_path = str_replace('/news-items/', '/', $page->realPath); } }); Caveats
      The custom paths will be used automatically for links created in CKEditor fields, but if you have the "link abstraction" option enabled for CKEditor fields (Details > Markup/HTML (Content Type) > HTML Options) then you will see notices from MarkupQA warning you that it is unable to resolve the links.
      Installation
      Install the Custom Paths module.
      Uninstallation
      The custom_path field is not automatically deleted when the module is uninstalled. You can delete it manually if the field is no longer needed.
       
      https://github.com/Toutouwai/CustomPaths
      https://modules.processwire.com/modules/custom-paths/
    • By Greg Lumley
      Hi! I'm busy building a blog into my first test/learning/free/clients/project 😁

      I've had a look at all the blog examples and there seem to be different ways of doing it. (the point of Processwire, I know)

      It seems this is generally how it's done:
      Master Blog Page
        - Blog Post Child Page
        - Blog Post Child Page
        - Blog Post Child Page What I'm particularly interested in is the Categories. What would you advise?
      Repeater Field?
      Tags?

      I think I've even seen Categories set up as Children of a master Category page too. The pages were hidden containing no 

      What would you recommend? 

      Thank you! 
      Greg. 

      Bare with me, I'm bashing my way through while I learn. 
    • By AndZyk
      Hello,
      I am currently building a intranet which will be hosted on the local network of a company. This intranet has many links to files on their fileserver with the protocol file://.
      So for example the links look like this file://domain.tld/filename.ext
      When I try to insert such a link into a URL field, I get the error, that only the protocol http:// is allowed. When I try to insert such a link into a CKEeditor link, it gets stripped out. Is it possible to insert such links into the FieldType URL and CKEditor.
      I know that I could use a FieldType Text or insert a RewriteRule in the .htaccess file, but I am looking for a more elegant solution. 😉
      Regards, Andreas
    • By MateThemes
      Hello everyone!
      I use ryans blog site profile to build my template around it. I use my mamp pro setup with php 7, mysql 5 and apache server. On my local setup the following code works fine:
      <?php foreach(page()->children as $category): ?> <a class='uk-link-reset' href='<?=$category->url?>'> <div class='uk-card uk-card-default uk-card-hover uk-card-body'> <h3 class='uk-card-title uk-margin-remove'><?=$category->title?></h3> <span class='uk-text-muted'><?=$category->numPosts(true)?></span> </div> </a> <?php endforeach; ?> It is the same code as ryan used it, only my css classes. On my live server with the same setup as mamp pro i got following error:

      Does anyone have the same error in this context?
      Thank you very much for your help!
×
×
  • Create New...