I need the $posts object accessible in every template file.

I need the $posts object accessible in every template file.

Postby chromos on Tue Feb 12, 2008 5:17 pm

Is there an easy way to do it?
Or do i have to look into the source to get it working?

I want to create some kind of taskbar (with images).
It's working so far but, well, of course only in main.template.

So i need the $posts object accessible in the other template files as well.

regards,
fabian
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel

Postby jondaley on Wed Feb 13, 2008 4:12 pm

I don't think that should be too hard, though you might take a look at the recent comments plugin and see if you need to do any code. If I make a guess at what you want, the best way is to probably copy recentcomments and make your own plugin and modify the SQL that it uses to return what posts you want.

If you just need to be able to get random posts from random pages, and you already know the article ids, the recent comments plugin has a function for that.

You could also do it by modifying the core code, but then you have to worry about upgrades, and your stuff getting overwritten, so a plugin is a better solution.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Postby chromos on Wed Feb 13, 2008 5:54 pm

thanks for your answers jondaley. I really appreciate them. I' ll give your suggestions a try tomorrow.

BTW what happened to phunkphorce?
If there is help needed with the lifetype project just let me know.
It's somehow a bit too calm in these forums here imho.

regards,
fabian
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel

Postby jondaley on Thu Feb 14, 2008 1:00 am

It has been kind of quiet. I know some folks have been busy. And it seems that there haven't been that many questions either - I have thought that since I know folks are still downloading the packages like crazy, that people must simply be pretty happy with the 1.2.5 and 1.2.6 releases, and don't have many problems.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Postby chromos on Thu Feb 14, 2008 10:18 am

Well, if people are still downloading like crazy, it will be fine.

Is the recent comments plugin you were talking about also in the 1.2.5 package?

BTW: as it is popping to my mind ... some weeks ago i wrote a question about getting the archives link by year and you gave me a little piece of code of yours.
It was exactly what I was searching for. But I haven't been able to get a link pointing to, let's say, the year 2007. I solved it by myself with a little php hack but it's only working for the url scheme i am currently running and really not a nice thing to do. I substr() the link e.g. from .../archives/1/200711 to .../archives/1/2007 to get the posts from the year 2007. Beeing a perfectionist i want it to work with every url scheme ;) any ideas?
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel

Postby jondaley on Thu Feb 14, 2008 10:17 pm

recentcomments is on sourceforge - with the rest of the plugins - it doesn't come installed by default, if that is what you are asking.

If you want stuff to work with each URL scheme, you'll want to use the getArchiveLink($date) function which will generate the right link for whatever scheme. If I am remembering correctly, you can use $url->getArchiveLink($date) to access the /class/net/*requestgenerator.class.php classes.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Postby phunkphorce on Wed Feb 20, 2008 4:45 pm

chromos wrote:BTW what happened to phunkphorce?


phunkphorce has been kind of busy lately, but there's other people in these forums that can provide the same kind of support or even better, so he won't be really missed :)
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby jondaley on Fri Feb 22, 2008 10:41 am

hrm - I for one definitely wouldn't say that he wouldn't be missed...
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Postby chromos on Fri Feb 22, 2008 7:19 pm

yeah same here!
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel

Postby chromos on Sat Feb 23, 2008 7:00 pm

ok me again.

1. I changed my URL scheme to custom and e.g. {$url->getArchiveLink($year)} is returning .../lifetype1.2.6/archives/1970/01/01.
My settings are exactly the same as in the wiki (it's a one user blog so i used these from: How to customize URLs when we are the only user in the site)

It's working though for Plain and Search Engine Friendly. ModRewrite is strangely enough not working at all(using XAMPP 1.6.6 on windows).

2. you have a lot of spam in the news about lifetype 1.2.6

regards,
fabian
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel

Postby jondaley on Sun Feb 24, 2008 2:05 am

chromos wrote:1. I changed my URL scheme to custom and e.g. {$url->getArchiveLink($year)} is returning .../lifetype1.2.6/archives/1970/01/01.

Hrm, yes, I see that getArchiveLink doesn't know how to return links to the year.

Look in class/net/customrequestgenerator.class.php. You'll probably need an additional line or two to have an if(strlen(...)== 4) case.

2. you have a lot of spam in the news about lifetype 1.2.6

Thanks, I marked it as spam. I need to install a security plugin to block that junk.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Postby chromos on Sun Feb 24, 2008 12:35 pm

ok i fixed it ...

Code: Select all
if( strlen($date) == 4 ) {
    $params = Array( "{year}" => $date,
                             "{month}" => "",
                             "{day}" =>  "",
                             "{blogname}" => $this->_blogInfo->getMangledBlog(),
         "{blogowner}" => $ownerInfo->getUsername(),
                             "{blogid}" => $this->_blogInfo->getId());
   
     $archiveLink = $this->getBaseUrl().$this->_replaceTags(
                                                                             $archiveLinkFormat,
                                                                             $params );
     $archiveLink = substr($archiveLink, 0, -1);
     return $archiveLink;
}


i have to use substr because replaceTags() returns a link with a trailing double slash and that's not what we want.
Maybe i should fix this one too? =)

That's why this code hast to be entered on top of the other to strlen cases.

regards,
fabian
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel

Postby chromos on Tue Feb 26, 2008 12:40 pm

argh ... i don't get it.

I am actually writing the plugin you suggested ... getting the articles from a specified category only. But how do i get the category id?

here is what i tried:

Code: Select all
lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );         
$articles = new Articles();
$cats = new BlogCategories();
           
$id = $cats->getBlogCategories("News", -1, DEFAULT_ITEMS_PER_PAGE);
                 
return $articles->getBlogArticles(1,-1, -1, $id, POST_STATUS_PUBLISHED, 0, 0, "", -1);


getBlogCategories() returns zero although the searchterm is actually an existing category.
Any Ideas?
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel

Postby chromos on Tue Feb 26, 2008 12:51 pm

chromos wrote:argh ... i don't get it.

I am actually writing the plugin you suggested ... getting the articles from a specified category only. But how do i get the category id?

here is what i tried:

Code: Select all
lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );         
$articles = new Articles();
$cats = new BlogCategories();
           
$id = $cats->getBlogCategories("News", -1, DEFAULT_ITEMS_PER_PAGE);
                 
return $articles->getBlogArticles(1,-1, -1, $id, POST_STATUS_PUBLISHED, 0, 0, "", -1);


getBlogCategories() returns zero although the searchterm is actually an existing category.
Any Ideas?


ok apparently i read way too much docu ;) and missed that it is returning an array.
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel

Postby chromos on Tue Feb 26, 2008 1:50 pm

ArticleCategories is the correct class ... i finally figured it out.

working pretty well.

thanx jondaley
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel

Next

Return to Templates

cron