Joomla Field - Title with alias

9 år 9 månader sedan #650 av Geir
Here is a quick recipe to create URL safe aliases. It does not include routing, if you need it, check out the Joomla! docs .

1. Create title and alias in your component, as regular Joomla textfield.

2. Build your component and unzip component.

3. Locate  com_yourComponent\administrator\tables\yourTable.php and add
 jimport('joomla.filter.output');
    if (empty($this->alias))
    {
       $this->alias = $this->title;
    }
    $this->alias = JFilterOutput::stringURLSafe($this->alias);
to public function check()

4. Locate com_yourComponent\administrator\models\forms\yourTable.xml and replace title and alias fields with
<field name="title" type="text" label="JGLOBAL_TITLE"
         description="JFIELD_TITLE_DESC"
         class="input-xxlarge input-large-text"
         size="40"
         required="true" />
      <field name="alias" type="text" label="JFIELD_ALIAS_LABEL"
         description="JFIELD_ALIAS_DESC"
         hint="JFIELD_ALIAS_PLACEHOLDER"
         size="40" />
5. Locate com_yourComponent\administrator\views\yourTable\tmpl\edit.php and remove the title and alias fields, then add 
<?php echo JLayoutHelper::render('joomla.edit.title_alias', $this); ?>
as the first line after the opening form tag

That's it! If I haven't forgotten anything at least (if I have, let me know so I can correct it).

Your title and alias fields are now using joomlas own strings, so you could clean up your language files as well.
Följande användare sa tack: Fusió d'Arts Technology S.L., Andres Maeso, Juanjo vazquez real, Marinus Moerland, Pontus Karlsson, Виталий

Be Logga in eller Skapa ett konto ansluta till konversationen.

9 år 8 månader sedan #699 av Gosling Cools
Svar från Gosling Cools i ämnet Joomla Field - Title with alias
Didn't know about number 5. Great!

Be Logga in eller Skapa ett konto ansluta till konversationen.

9 år 1 månad sedan - 9 år 1 månad sedan #1034 av Geir
Svar från Geir i ämnet Joomla Field - Title with alias
It's great to see you have implemented the routing feature for alias field.
My temporary solution however, is still valid, as it adds the missing parts of your implementation.

- Title/alias layout.
- URLsafe alias autogenerated from title
Bilagor:
Last edit: 9 år 1 månad sedan by Geir.

Be Logga in eller Skapa ett konto ansluta till konversationen.

Sidan laddades på: 0.051 sekunder
Powered by Kunena Forum

We use cookies so that you can place orders and we can provide a better service. You can control the use of cookies at the individual browser level. If you reject cookies, you may still use our website, but your ability to use some features or areas of our website may be limited.