Entry Object

The two main objects the Dreamwidth source code uses are Entry and User. The Entry object stores information about a Dreamwidth post. It's definition resides in cgi-bin/LJ/Entry.pm and if you want to create a new object of this type you need to do so by calling LJ::Entry. I will summarize some of the important methods and attributes here.

=Creating an Entry object=

Function: new
will return an Entry object. So will

provided that $u is the User object of the user this entry belongs to (in the case of communities, this is the community, not the poster) and $jitemid or $ditemid is the ID of an existing entry.

Please note that this can also create a 'zombie-entry' if the ID does not actually exist, so you need to make sure it is the correct one.

Function: new_from_url
Sometimes it is useful to just construct a new Entry object from the URL of the entry. This can be done by calling

where $uri is the URL of the entry.

=Entry object functions=

For the purpose of this section, $entry will always be our Entry object.

Function: ditemid
returns the ditemid of that entry.

Function: jitemid
returns the jitemid of that entry.

Function: user/userid
returns the User object of the account this entry was posted in, which is not necessarily the User object of the account this entry was posted by. For communities, the community's User object is returned.

just returns the user ID of that user.

Function: poster/posterid
returns the User object of the account this entry was posted by, which is not necessarily the User object of the account this entry was posted in.

just returns the user ID of that user.

Function: reply_url
returns the correct ?mode=reply URL of your entry.

Function: security
returns the security level of the entry as a string. This can be 'public', 'private', or 'usemask', which is members-only/access-locked in some way.

Function: url
returns the permalink (the one without any arguments) to the entry.

However, it can also be passed arguments. The most-often used are:

which returns the link to the ?mode=reply page, just as

does; and

which returns the link to the #comments anchor.

Function: valid
As it is possible to construct 'zombie-entries' with invalid item IDs, you can check whether an entry actually exists using

which will return either 1 or 0.