27 Posts
Yusuf
8 years ago
8
Topic


Hi,
I have this error below whenever my form is submitted with an article title that is in existance.

** Error: Another article from this category has the same alias (remember it may be a trashed item). An error has occurred. **

Version: Seblod 3.7.2, Joomla 3.4.5

Any help will be appreciated.
Thanks for your time

Get a VIP membership
1283 Posts
Bucklash
8 years ago
3
Level 1

Hi

The alias has to be different. I have changed the value of a field by concating the alias and userid with the beforestire field.

Bucklash

27 Posts
Yusuf
8 years ago
2
Level 2

Hi Bucklash,

Thanks for stopping by. However, am confused with your suggestion am still new to seblod.

Can you kindly explain clearer?

Thanks for your time.

1283 Posts
Bucklash
8 years ago
1
Level 3

Hi Yusuf

It seems to me that you have added fields to your Article Content Type. 

So what alterations have you made?

What field is storing the title? - The fields storage should be Standard | Article | title

What value is in the DB under title, and alias? - ie if it is a date then nothing is going to to the db so it defaults to time etc...

I have had the same situation and it has been my doing something silly, each time!

Bucklash

27 Posts
Yusuf
8 years ago
0
Level 4

Hi,

i am using custom Article Content Type and i have added fields to your Article Content Type.

The value in the DB under title, and alias are as seen in image above.

I don't really know what to fix?

Whenever a content with the same title is submitted it returns error?

Thanks

8 years ago
2
Level 1

Hello Yusuf,

It's a Joomla feature. You can't have a content with the same title (so the same alias) in the same category.

Two solutions :

  • Add the Ajax validation on the title field, so the user will be alerted that the title is already existing, before submitting.
  • Generate a unique alias before the article is stored, by using the Plugin Code "Before Store"


Regards.

Lionel

8 years ago
1
Level 2

Hi Lionel

This is exactly the same issue I have, where I have events with the same name. My solution would be to add the article ID number to the front of each alias, thereby making the alias unique. Do you think this would be possible? If not perhaps a random 4 digit number.

1283 Posts
Bucklash
8 years ago
0
Level 3

Hi offthehookdesign

I wanted to see if I could concat the alias with the article id, guaranteeing unique alias... here is my code which goes in the afterstore plugin/field. It could probably be a bit more concise and lean... 

I get the alias just stored, concat it with the id and store back in the alias db column
// assign pk value
$configPk = $config['pk'];
// Get a db connection.
$db = JFactory::getDbo();
// Create query object
$query1 = $db->getQuery(true); 
// get alias from article with id of 'pk'
$query1
->select($db->quoteName(array('alias')))
->from($db->quoteName('#__content'))
->where($db->quoteName('id') . ' = '. $configPk);
// load the result, loadAssoc is for use with arrays. In this instance there is only one value, but other times you might need to get more than one value
$db->setQuery($query1);
$result1 = $db->loadAssoc();
// store the result as variable
$result1Alias = $result1['alias'];
// Create query object
$query2 = $db->getQuery(true);
// select the column to update and with what
$fields = array(
    $db->quoteName('alias') . ' = ' . $db->quote($result1Alias . '-' . $configPk)
);
// Conditions for which records should be updated.
$conditions = array(
    $db->quoteName('id') . ' = ' . $db->quote($configPk)
);
$query2->update($db->quoteName('#__content'))->set($fields)->where($conditions);
 
$db->setQuery($query2);
 
$result = $db->execute();
<br>

Inserting,_Updating_and_Removing_data_using_JDatabase

Selecting_data_using_JDatabase

changing-the-joomla-message-after-a-submission-of-a-seblod-form

   

Bucklash

27 Posts
Yusuf
8 years ago
0
Level 1

Hi,

Thanks for your contributions. I finally got a plugin to fix this at: https://www.seblod.com/community/forums/fields-plug-ins/unique-alias-automaticly

Thanks for you time.

Get a Book for SEBLOD