How to get bloginfo object from head.template??

How to get bloginfo object from head.template??

Postby yihect on Fri Jan 14, 2011 3:25 am

Hi, I'm a newbie of lifetype.

I know in header.template, we can use a global object named $blog from which we can get information about the current blog, such as the name and description. But how to get bloginfo object from header.template?????


I want to write a plugin which can gather user's plugin-defined preference setting. Now I have know if the names of these setting option are all prefixed with a plugin_xxxx_ prefix, they will be got using BlogSettings::getValue(). And I have know I can get BlogSettings from bloginfo?


So how to get bloginfo from head.template??? Or get BlogSettings from head.template's context directly??? I want to setting different looks according these user set options??? Thanks.
yihect
 
Posts: 5
Joined: Thu Jan 13, 2011 9:16 pm
LifeType Version: 1.2.10

Re: How to get bloginfo object from head.template??

Postby jondaley on Fri Jan 14, 2011 3:56 am

The blogInfo object is available to the templates as simply $blog. Any function that is in class/dao/bloginfo.class.php, you can call using $blog->getAbout() etc.

Plugins can define functions in the main entry file for the plugin. See authimage (or lots of plugins for an example). The most common setting plugins use is isEnabled(), and that simply returns a boolean whether it is turned on or not.

See this document for some more specifics. (and there are other dev documents on the wiki's home page)
http://wiki.lifetype.net/index.php/Plugin_Development

Have you tried:
{assign var="mysettings" value=$blog->getSettings()} and then:
{assign var="blah" value=$mysettings->getValue("plugin_asdsad_qweqwe")}

I haven't tried it myself, but it seems like it should work.
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 bloginfo object from head.template??

Postby yihect on Sat Jan 15, 2011 12:00 am

Hi jondaley:

I have add my customed plugin, and the config page of my plugin can be seen in admin interface.

But when I rewrote standard/header.template like following and update it into my website, all blogs except the admin blog can not be accessed.

Code: Select all
....
<div id="Title"><h1><a href="{$url->blogLink()}">{$blog->getBlog()}</a></h1>

   {assign var="mysettings" value=$blog->getSettings()}
   {assign var="mypl_enable" value=$mysettings->getValue("plugin_mypl_qweqwe")}
   
   {if $mypl_enable}
     <a href="www.google.com"> google </a>
  {/if}

</div>
.....


I think it is due to some wrong code in this template. so I delete those code I added and upload it, but the situation hasn't changed.
The other blogs except admin blog all can't be accessed. What's wrong with it?
yihect
 
Posts: 5
Joined: Thu Jan 13, 2011 9:16 pm
LifeType Version: 1.2.10

Re: How to get bloginfo object from head.template??

Postby yihect on Sat Jan 15, 2011 2:48 am

Now, the other blogs can accessed.

But there isn't anything in header div area of blogs, even if I rewrote the stand/header.template like this:

<code>
<div id="Title"><h1><a href="{$url->blogLink()}">{$blog->getBlog()}</a></h1>

<a href="www.google.com"> google </a>

</div>
</code>

That's why?? The blogs are using stand template.
yihect
 
Posts: 5
Joined: Thu Jan 13, 2011 9:16 pm
LifeType Version: 1.2.10

Re: How to get bloginfo object from head.template??

Postby jondaley on Mon Jan 17, 2011 12:42 pm

You should look in your apache error log - it will probably show a php error in your template file. It will point to the generate php file in tmp/X/%%asdlasdlskdjasd%% and you can check the line number given in the error there, and then compare that to your template code and figure out where you made a typo. Or - revert back to a given template and then make your changes slowly until you get the error.
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 bloginfo object from head.template??

Postby yihect on Mon Jan 17, 2011 9:59 pm

En, thanks for your so detailed explanation. According to your reply on this and other page, I had worked out my plugin.
And It works very well, thanks.
yihect
 
Posts: 5
Joined: Thu Jan 13, 2011 9:16 pm
LifeType Version: 1.2.10


Return to Templates

cron