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
The Public Knowledge Project Support Forum is moving to

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.
Posts: 18
Joined: Tue Oct 29, 2013 10:06 am

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 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,

Site Admin
Posts: 910
Joined: Tue Jan 10, 2006 6:20 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 file contains the SQL for accessing the article table in the database, and for assembling the Article Object (see _*FromRow method in there). The 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.


Posts: 18
Joined: Tue Oct 29, 2013 10:06 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!

Return to “OJS Development”

Who is online

Users browsing this forum: No registered users and 1 guest