How to get extra fields in external site

How to get extra fields in external site

Postby zaanen on Sat Feb 12, 2011 8:42 am

Hi All,

I used the wiki page to get a code for external non blog site. That part is working perfect for me.
Now i added a few extra fields that i want to load on that page to.
I added the fields albumimage and albumlink.

This is the code i already have in use.

Code: Select all
            <?php

   if (!defined( "PLOG_CLASS_PATH" )) {
        define( "PLOG_CLASS_PATH", "../blog2/" );
    }

   // necessary classes
   require_once( PLOG_CLASS_PATH."class/bootstrap.php" );   
   lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
   lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
   
   //
   // id of your blog, you need to know this one before starting and can easily
   // be found out in the admin interface
   //
   $blogId = 1;
   
   // Load the blog articles. This method call returns an array of Article objects
   // or an empty array if there is none
   // See http://lifetype.net/api/class_articles.php#aee20e131c51a6fdbd4f0d24e16e3c76
   $articles = new Articles();
   $blogArticles = $articles->getBlogArticles(
         $blogId,                 // our blog id
         $date,                     // date, we don't care
          $aantal,                      // amount of posts to fetch, increase this if needed
         $categoryId,                      // category id, but we don't care
         POST_STATUS_PUBLISHED    // only the ones that are published         
                                  // this method can take more parameters but we don't need them
      );

    if( count( $blogArticles ) == 0 ) {
     print("Sorry, there are no posts to display" );
   }
   else {
      // loop through the posts and show them
      foreach( $blogArticles as $article ) {
         // See http://lifetype.net/api/class_article.php for more information regarding the Article class
         $blog = $article->getBlogInfo();
         // This returns an object of type BaseRequestGenerator
         $url = $blog->getBlogRequestGenerator();
         // This returns an object of type UserInfo
         $user = $article->getUserInfo();
         // This returns an array of ArticleCategory objects
   //      $categories = $article->getCategories();
         // And this returns the blog locale of type Locale
         $locale = $blog->getLocale();
         // Date when this was posted, of type Timestamp
         $date = $article->getDateObject();
         
?>

<div id="<?php echo $article->getTopic()."title"; ?>">
<p>
<h2><?php echo $article->getTopic(); ?></h2>
<br/>
 <?php echo $article->getIntroText();
 
 if($article->hasExtendedText() =='TRUE'){?><a id="<?php echo $article->getTopic(); ?>" href="javascript:toggle2('<?php echo $article->getTopic().'extra'; ?>','<?php echo $article->getTopic(); ?>');" >meer</a> <div id="<?php echo $article->getTopic().'extra'; ?>" style="display: none"> <?php echo $article->getExtendedText().' </div> ';  } ?><br/>
 Posted by: <?php echo $user->getUsername(); ?> on the <?php echo $locale->formatDate($date); ?>


What do i have to add to see to see albumlink and albumimage to ?
zaanen
 
Posts: 21
Joined: Thu Jun 07, 2007 8:15 am

Re: How to get extra fields in external site

Postby jondaley on Sat Feb 12, 2011 10:38 am

Do you know the album id, or do you need to figure that our dynamically? ie. can you hard-code the albumid like you have the userid in your current code?
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: How to get extra fields in external site

Postby jondaley on Sat Feb 12, 2011 10:43 am

There isn't code already written for that (as far as I remember).

You will need code from class/gallery/dao/galleryalbums.class.php

$ga = new GalleryAlbums();
$ga->getUserAlbums( $ownerId, $onlyShownAlbums = false, $page = DEFAULT_PAGING_ENABLED, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )

That will give you all of the albums that the user owns.
If you know the album id, then you can use:

$album = $ga->getAlbum( $id, $ownerId = -1, $fetchResources = true, $onlyShownAlbums = false )

once you have an $album object (use print_r($album); to look at it to make sure it looks right), then you can use functions from class/gallery/dao/galleryalbum.class.php like this:
$name = $album->getName()
$numberOfPictures = $album->getNumResources();
etc.

(General programming note: any parameter in the function that has an = in it means the parameter is optional, so you could simply do $albums->getAlbum(1); to get the first album.)
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: How to get extra fields in external site

Postby zaanen on Sat Feb 12, 2011 11:21 am

Sorry John i misstold perhaps because its a album thing.

I created 2 extra textfields where i put a url to the album and album image.
So its a extra textfield i want to show or place somewhere.
In the textfield will be something like http://zaanenalbums.homeip.net/album/image.jpg as clear text.

I want to display those added text boxes tot the external blog.

So it is not the gallery from lifetype i want to include.
But just the value of two added text boxes.
zaanen
 
Posts: 21
Joined: Thu Jun 07, 2007 8:15 am

Re: How to get extra fields in external site

Postby jondaley on Mon Feb 14, 2011 10:13 am

Are you talking about the custom fields?
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: How to get extra fields in external site

Postby zaanen on Mon Feb 14, 2011 10:18 am

Yes these 2 are a custom textfield
zaanen
 
Posts: 21
Joined: Thu Jun 07, 2007 8:15 am

Re: How to get extra fields in external site

Postby jondaley on Mon Feb 14, 2011 11:31 pm

The smarty samples are here, and then you can convert this code to php.

http://wiki.lifetype.net/index.php/Tips ... tom_fields
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch


Return to Other Problems

cron