Subject: Custom fields in stories

Posted on: 27/02/19 06:28pm
By: alb3rt

Hello guys,

Is it possible to add some custom fields to "stories" through a plugin? I do not want to modify lib-article.php (and others).

I am reviewing the wiki and can not find any information about it.

Regards

Re: Custom fields in stories

Posted on: 28/02/19 07:12am
By: Laugh

This was something I was thinking of adding at the time I added the topic control but it was never implemented. The user registration is the only thing that allows plugins to add extra fields when a new user is added or edited.

You could maybe add the functionally indirectly without any core code changes. Your plugin would have to have a separate edit page for the article custom fields though.

To display the custom fields when the article is displayed on the site take a look at the function PLG_templateSetVars in lib-article.php. Then read about it in lib-plugins.php. The article template does get handed off to other plugins. At this point you should be able to read the article id template variable (I think one is set) and then use the id to add the required info from the custom fields.


Re: Custom fields in stories

Posted on: 17/03/19 03:28am
By: alb3rt

I solved it in the following way that is not the most elegant but it works.

1. I create the article normally.
2. When reading the article I pass a url through the lib-custom.php that takes me to an additional script (~/admin/article_extra.php) where I add the additional fields that I need, I can even add a highlighted image with the file -manager.
3. Again through the lib-custom.php I get the values of my additional fields and I pass them to my article.
4. The only modifications I made to the original file (~/admin/article.php) was to add a couple of lines: 1) to delete my additional fields when the article is deleted and 2) update the ID if necessary.

What really needed with the additional fields is: 1) To be able to put a different author to the article and 2) To be able to add a highlighted image.

Screenshots:




Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=96986