Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 07:36 am EST
Geeklog Forums
Custom fields in stories
Status: offline
alb3rt
Forum User
Regular Poster
Registered: 10/30/06
Posts: 71
Location:Mexico City
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
D Web Studio - www.d-webstudio.net
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
D Web Studio - www.d-webstudio.net
34
28
Quote
Status: offline
Laugh
Site Admin
Admin
Registered: 09/27/05
Posts: 1470
Location:Canada
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.
One of the Geeklog Core Developers.
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.
One of the Geeklog Core Developers.
33
28
Quote
Status: offline
alb3rt
Forum User
Regular Poster
Registered: 10/30/06
Posts: 71
Location:Mexico City
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:
D Web Studio - www.d-webstudio.net
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:
D Web Studio - www.d-webstudio.net
25
35
Quote
All times are EST. The time is now 07:36 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content