How much of a rewrite for a plugin from Fabrik 3-> Fabrik 4?

thellie

Member
I'm past the "Hello world!" stage of PHP coding, but not much further - I tend to hack similar code until I get it to work, kinda work, or give up (@troester - Cannot use placeholders in PHP form plugin... is one of my (many) failures :) )

However, if I opened up a plugin folder from a F3 download (I need the articles form plugin) and were to upgrade it to F4, how much of a task is it? Do all files need rewriting? Is there an "Upgrading Plugins For Dummies" that can be followed?

I have a feeling it's beyond me, but as they say in Thailand, if you don't try, you don't know...
 
I don't imagine it is a big job to get it working. Why not just enable it in a test J4 install and see what happens when you try and use it. If it fails you may be able to hack it or report the problem here and one of us may be able to help.
 
article plugin is one of the complex omes but I'm pretty far

Gesendet von meinem SM-G930F mit Tapatalk
 
I'm past the "Hello world!" stage of PHP coding, but not much further - I tend to hack similar code until I get it to work, kinda work, or give up (@troester - Cannot use placeholders in PHP form plugin... is one of my (many) failures :) )

However, if I opened up a plugin folder from a F3 download (I need the articles form plugin) and were to upgrade it to F4, how much of a task is it? Do all files need rewriting? Is there an "Upgrading Plugins For Dummies" that can be followed?

I have a feeling it's beyond me, but as they say in Thailand, if you don't try, you don't know...

I have a requirement for this plugin as well so I've 'hacked' a version of this, which is working but needs some more testing. Some of it will need a complete rewrite to do it the "Joomla 4" way but this can be done at a later stage.

I'll do some more testing later but if you want to do some testing I can send it over to you.
 
I am unable to download that attachment from the forum thread, "The requested attachment could not be found."

Unfortunately the change log is meaningless to me as I am unable to get anything until a new release comes out.

It's probably safer for me to stay out the forums, I'm creating extra work for myself :)
 
Oh, sorry. The download should be fixed (no idea why the file was gone).
And here, too
article.zip
 

Attachments

  • article.zip
    52.3 KB · Views: 63
Oh, sorry. The download should be fixed (no idea why the file was gone).
And here, too
article.zip

Looks pretty much similar to what I did. What had me stumped was the #__workflow_associations table which you have to add to even if you are not using it. I was creating the articles but they were not showing up in the backend until I populated the workflow table. This, I believe, is due to doing it the Joomla 3 way using "
$table = JTable::getInstance('Content', 'JTable', array());". Doing it the Joomla 4 way should deal with it automatically.

Code:
$app = Factory::getApplication();
$mvcFactory = $app->bootComponent('com_content')->getMVCFactory();
$articleModel = $mvcFactory->createModel('Article', 'Administrator', ['ignore_request' => true]);


The one thing that might need to be adjusted and I haven't done it on mine either yet is the removal of the items from #__workflow_associations if the record is deleted and set to remove article.

I'll test your one on another installation later and add any additional code for the removal of #__workflow_associations records..... if it's not already in the code.
 
That may have something to do with the issue I've just come across. The plugin works properly - ie it creates the article and populates the table.
The articles appears in the backend correctly (I've only just started this so I've made just 2 articles).

The first article, I had selected the wrong content element for the article title, so I deleted the article (trash and empty trash). Then I resaved the form, which I expected to create a new article. Nothing appeared in the backend articles list, for any of my subsequent attempts.

The second article has saved correctly.

The problem, in summary, is that after trashing the first article, no further articles were created in the articles list
 
Ideally any articles you want to be removed should be removed via the Fabrik record, or simply edit the original record and change the content. When you delete the Fabrik record it should delete the associated article, providing you have enabled that option.

I'll re-create your scenario later when I'm testing the other parts, I can't remember if any code was in place to prevent that happening. There may have been something that doesn't work now due to the changes or we simply didn't account for it. I think it was Fabrik 2 the last time I used this plugin.
 
Just a quick update on this, the article plugin that @troester provided.

Creating articles works fine.
Deleteing articles works fine but we need to add code in to remove the records from #___workflow_associations which is easy enough.

Modifying records doesn't appear to update the articles though. I had a quick look but haven't worked out why yet, all the data appears to be correct just before we $item->store(); Hopefully it's not a bug with using Table::getInstance('Content') as Joomla will unlikely fix it and we will have to re-write some of this code using MVCFactory. Hopefully it's something obvious that I have overlooked. I will look into this over the weekend as I have a full day today.
 
I tested the same above plugin on Joomla 3, (just had to add workflow tables), and everything worked there fine.

For Joomla 4, the records are updating but the article content is not changing. I wonder what I am doing different to you.
 
Okay, I think I have solved this. I created an element for all the fields so I could test them all, the only one that I didn't change from a standard element was 'publish down'. That stopped everything working, as soon as I changed that element to a Jdate it worked......... at least that's what I think is causing it. I really will have to test later as I'm supposed to be doing other stuff. :D



upload_2023-7-7_14-45-11.png
 
Okay, I'm going all out on this one as I think the article plugin is an underrated feature of Fabrik and it's a great CCK feature. I don't think this plugin has had much attention since the Fabrik 2 days so I'm adding extra features to align it with Joomla 4. The majority of the features are optional and will load the defaults if not used, this simplifies things and keeps it backward compatible.

I've added extra fields for images, "alt text", "caption" etc and created and extra tab for "article links". These are all things I'll be using on a new site so it's up to you whether you want it in the core plugin.

I'm a little confused why intro \ full images are rendered through Fabrik though, I don't see this is necessary. Either way some extra work needs to be focused in this area as I believe it's creating invalid JSON in content -> images

I've also added the code to remove entries to the #___workflow_associations table on record deletion. I'll post a zip in the next couple of days after more testing.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top