OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



New table column - how to get to the value?

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

New table column - how to get to the value?

Postby Looted » Tue Oct 29, 2013 10:34 am

Hello everyone!

I'm writing in hopes of getting some guidance with my current task.

What I'm tryging to do:
I'm trying to add a new column to the articles table. For the sake of simplicity, let's say it shall hold integers 1-6. Now I need the journal editor to be able to set the value of an article (1 through 6), and I also need to read the value with smarty (so the articles value can be seen by author).

What am I asking for:
I have a very basic knowledge of PHP, enough to write and read from database. The structure of OJS is however very advanced, and I have a problem understanding, where should i write a function. From the technical documentation i understood, that i should be looking at EditorHandler.inc.php. Could anyone point me in the right direction, which files should I be modifying, to be able to write to the articles table as an editor, and read the value through smarty?

Any help or suggestions would be welcome.
With regards,
Looted
Looted
 
Posts: 18
Joined: Tue Oct 29, 2013 10:06 am

Re: New table column - how to get to the value?

Postby JasonNugent » Tue Oct 29, 2013 11:17 am

Hi Looted,

It will be more complicated than that. You'll need to modify the database schema, the DAO for the Article object, and the Article object class itself, in order to provide accessor methods. The ArticleDAO.inc.php file contains the SQL for accessing the article table in the database, and for assembling the Article Object (see _*FromRow method in there). The Article.inc.php file contains the Article class definition. You'll probably want to add a getSomething() and setSomething($value) method there.

In the Handler that generates the page you want to see or set that value on, you'll probably want to find the Form class that it references and add the necessary code bits to the readInputData(), fetch() and execute() methods in order to set the field on the form and then retrieve it. Finally, you'll need to modify the appropriate Smarty template that the form uses in order to display your value and let an editor set it.

The database schema is defined in a set of XML files located in the dbscripts/ directory. It's important to include your changes here in case you ever decide to run the upgrade tool. If you don't, you'll lose your new column.

Hope that's useful.

Cheers,
Jason
JasonNugent
Site Admin
 
Posts: 895
Joined: Tue Jan 10, 2006 6:20 am

Re: New table column - how to get to the value?

Postby Looted » Tue Oct 29, 2013 12:10 pm

That's very useful JasonNugent, thank you!
Looted
 
Posts: 18
Joined: Tue Oct 29, 2013 10:06 am


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 2 guests