WeStandWithUkraine

4 Posts
eniky
6 years ago
5
Topic

Hi,

i would like to redirect only one special content typ to a thank you page and only if the article is new.

I think it is only possible with a content plugin (onContentAfterSave). Its easy to find out if an article is new, but how to find out the content type of the content?

Is there an api call available? Or if there is none: Where to find the connection between content type and article in the database.

Any hints are appreciated.


Best regards

Patrick

Get a Book for SEBLOD
1279 Posts
Bucklash
6 years ago
0
Level 1

Hi Patrick

If you have the field associated with just the one content type then you can do what you want.

In your list and search type turn on debug, which is found in the config area of your template

Check out the sql query that you wil see on the front end.

That will tell you the relevant db tables ie #__cck_core, etc 

4 Posts
eniky
6 years ago
0
Level 1

Thanks Bucklash,

you point me the right way.

Here is the code of the plugin i build.

class plgContentEniky extends JPlugin
{

    function onContentAfterSave($context, &$article, $isNew)
    {

        if (!$isNew) {
            
            $db = JFactory::getDbo();
            $query = $db->getQuery(true);

            $query->select($db->quoteName(array('cck')));
            $query->from($db->quoteName('#__cck_core'));
            $query->where($db->quoteName('pk') . ' = ' . $db->quote($article->id));

            $db->setQuery($query);
            $type = $db->loadResult();

            if ($type = "mycontentype")
                JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_content&view=article&id=44'));

        } else {

            return true;

        }
    }
}

Many thanks

Best regards

Patrick

1279 Posts
Bucklash
6 years ago
1
Level 1

Hi

Great

Thanks for posting your example, and nice work in decoding my dodgy typing (I corrected it so I can work out what the hell I was trying to say)...

1279 Posts
Bucklash
6 years ago
0
Level 2

Hi

A Seblod way rather than Joomla might have been to have two save buttons

Button 1 is Save and has workflow 'add'

Button 2 is Save and has workflow 'edit'

Then in the button 1 config have it redirect to relevant menu item (googling 'redirect form after submission' gives a few forum posts on the question, ie frontend-form-redirect-after-submit-to-content)

4 Posts
eniky
6 years ago
0
Level 1

Hi,

This sounds more like the seblod way.

Thanks

Get a Book for SEBLOD