Hello,
I have a form set up that creates a new article on submit using the Save Data action. Everything appears to be inserting into the database correctly except for the alias field for the article. Originally I had the alias field to just try and pull the data from the 'Title' field I had on the form but that method just inserts an empty value into the database column. I realize that it is more complicated to generate the alias as it needs to convert the title into a string of some sort with '-'s between each word.
My question is what is the best way of accomplishing this? Ideally it would generate the alias based off of the Title of the article converting it into the proper format and also appending incremental integers to the end of it if the alias generated already exists in the database, just like how Joomla handles aliases if you happen to create a copy of an existing article.
I have a form set up that creates a new article on submit using the Save Data action. Everything appears to be inserting into the database correctly except for the alias field for the article. Originally I had the alias field to just try and pull the data from the 'Title' field I had on the form but that method just inserts an empty value into the database column. I realize that it is more complicated to generate the alias as it needs to convert the title into a string of some sort with '-'s between each word.
My question is what is the best way of accomplishing this? Ideally it would generate the alias based off of the Title of the article converting it into the proper format and also appending incremental integers to the end of it if the alias generated already exists in the database, just like how Joomla handles aliases if you happen to create a copy of an existing article.
Hi directivemsp ,
I would use Custom PHP before the Save Data action to do whatever needs to be done to create a clean alias string (there may already be a Joomla! class that you can load and use for this).
Bob
I would use Custom PHP before the Save Data action to do whatever needs to be done to create a clean alias string (there may already be a Joomla! class that you can load and use for this).
Bob
Hey Bob,
Thanks for the quick response. I was able to set up a custom php action that pulled the title field and ran the JFilterOutput::stringURLSafe function on it which returned the title field as the string needed for the alias.
I was able to get that custom php variable set as the alias in the database, which is a great, however there is no check set to see if that alias value is already in the database and if so append an integer value to the end of the alias.
If you could assistance with that portion of the set up that would be greatly appreciated!
Thanks for the quick response. I was able to set up a custom php action that pulled the title field and ran the JFilterOutput::stringURLSafe function on it which returned the title field as the string needed for the alias.
I was able to get that custom php variable set as the alias in the database, which is a great, however there is no check set to see if that alias value is already in the database and if so append an integer value to the end of the alias.
If you could assistance with that portion of the set up that would be greatly appreciated!
Read data action first, with the WHERE condition set to look for the alias using /like:%{var:alias}%. Order by desc, with LENGTH(alias) and alias (so if there are 11 or more with the same alias and incrementing numbers at the end, you get the highest number).
If it's found, use another PHP code block to take the alias string, check if there's a number at the end, and increment the number.
If it's found, use another PHP code block to take the alias string, check if there's a number at the end, and increment the number.
This topic is locked and no more replies can be posted.