Permalinks :: Section

By jenolan - January 30, 2015

As mentioned in another post I am starting to work on stuff again, slowly, slowly .. Have setup a couple of areas to play with and now working on how the SEO (Permalink) structure will work for my planned site. I will explain what I am trying to do before code change requests :-)

I add a 'permalink' field to the section, perfect it will now generate the link, purrfect, but all the links that are created are root level ie http://example.com/permalink now that is not going to work with multiple sections that could cause collisions. In my example the section 'Activities' might have an item 'LOC44 :: The Journey Home' that's a file category, by my blog section will have EXACTLY the same heading for a,well blog, about the new file. So now we can't have the same permalink. What s needed in the section editor, probably in advanced options is the ability to add the permalink prefix for all links from that section. So in the Activities section my prefix would be 'activity' rthen the link would be http://example.com/activity/permalink and my blog could be http://example.com/blog/permalink.

Get the idea?

Now when I looked to add this I notice that there is no way via a hook to add anything to the 'top menu' of the section editor. Quick and dirty I can add a check to see if the permalink plugin is installed (easy) and the add an additional field to the advanced option (again easy) then save the value (not so easy) for use by the permalink plugin. Do you have a preference?

Thanks,
Larry

---
<?= "Jenolan(Larry) :: Coding Since 1973" ?>
Peace and Long Life

By jenolan - January 30, 2015 - edited: January 31, 2015

In digging through the code I noticed that you have an enforced 'prefix' already, just it was not automatic. Rather than do a lot of hacking what I have changed it to do is that the prefix is automatically added to the url shown on the edit form, and is then added to the record automagically. Patch below attached.

Update: Wrong variable used patch 2 attached

---
<?= "Jenolan(Larry) :: Coding Since 1973" ?>
Peace and Long Life

By Dave - February 2, 2015

Hi Larry, 

Did this method from the readme.txt not work?  Or was there something different you were trying to do? 

To get started, edit the section you want to add permalinks to and add a new text field called "permalink". If you would like all the permalinks for this section to start with a prefix, such as /news/ or /news- then enter that as the "Default Value" for the "permalink" field in the field editor. If a "Default Value" is set, then permalinks will only allow values that start with that text.

I wasn't clear what the difference was?  Let me know how I can help or what the patch is intended to do and I'll check it out.

Thanks!

Dave Edis - Senior Developer
interactivetools.com

By jenolan - February 2, 2015

In the entry area, where you type the permalink instead of "http://mysite/" being displayed, you get "http://mysite/prefix/" (shown on the entry screen) AND it automatically adds the prefix to the link so the user is NOT required to type it every time. Much more friendly, why should the person entering the link need to know to always manually add the prefix? :-)

What I am heading towards with this, is that the prefix could contain a substitution value so that permalinks like a wordpress site can be done, ie the prefix is blog/{%Year%}/{%Month%} and so on, didn't want to mess with that quite yet as I was just making the prefix handler more pleasant.


Larry

---
<?= "Jenolan(Larry) :: Coding Since 1973" ?>
Peace and Long Life

By Dave - February 12, 2015

Hi Larry, 

Ok, sounds cool.

What about if we just supported PHP tags in the "Default Value" field, and could refer to the current record as $RECORD.  Would that let you do the  {%Year%}/{%Month%} bit? Perhaps with some more code.  Or maybe we could just add support for some of those placeholders in that field.

I'm imaging you want to do more than that, but I thought I'd put that out there.

Cheers!

Dave Edis - Senior Developer
interactivetools.com

By jenolan - February 13, 2015

yeah .. two bitz allowing 'macro' stuff plus resurrecting CALM. I am also looking at a Silex/Twig front end and as usual all sort of other mischief, you know me, always something else to code ;-)

---
<?= "Jenolan(Larry) :: Coding Since 1973" ?>
Peace and Long Life