favicon per blog basis?

favicon per blog basis?

Postby chromos on Sun Nov 16, 2008 10:50 am

I am actually also thinking about implementing favicons on a per blog basis.
It should be pretty straightforward to implement because there is much code that can easily be reused.

Any thoughts on it?
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel

Re: favicon per blog basis?

Postby jondaley on Sun Nov 16, 2008 10:55 am

You could put in a modrewrite rule with the blogname as the redirect. Depending on how you have the custom URLs and resource URLs setup, you could simply have it redirect to a resource named favicon.ico in their blog (and you could even have a rewriteCond that checks if the file is there, and if it isn't, use the default one).

I'd expect you'd just need a two line rewritecond/rewriterule and no php 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: favicon per blog basis?

Postby chromos on Sun Nov 16, 2008 1:50 pm

Hm I guess I don't understand. I have no clue about this modrewrite stuff yet.
But I'll figure that one out too.
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel

Re: favicon per blog basis?

Postby jondaley on Mon Nov 17, 2008 5:25 pm

Hrm, so, now that I sat down to try to actually write the rules, I forgot that you don't know the blogId at the apache level, unless you are using certain types of URLs (and not for custom URLs, which is probably what everyone is using (or should be, I think)).

If you didn't care about making it way user friendly, you could still do it simply, by internally redirecting favicon.ico requests to /favicon/%HTTP_HOST.ico and then create a favicon directory and upload the images to it, named coolblog.yourdomain.com.ico or something like that.

To do it within the resources section (allowing users to modify it whenever they wanted), you'd need a plugin, and I can't think of a similar plugin at the moment. The plugin would simply take the blogId and look in /gallery/$blogId/favicon.ico.

Oh! You can do it in the templates:
Code: Select all
<link rel="shortcut icon" type="image/x-icon"
      href="{$url->blogLink()}gallery/{$blog->getId()}/favicon.ico" />


And, as an extra bonus, it even works - I am now using that code on my blog.
So, the only thing that doesn't work, is if the person doesn't upload a favicon.ico, it has a 404 request for that. I suppose you could even have an .htaccess rule that checked if the favicon.ico didn't exist and redirect it to the default one. Hrm. that's probably worth a feature request for LT2.0.
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: favicon per blog basis?

Postby chromos on Tue Nov 18, 2008 10:24 am

nice one jon and thanks!

Sorry bothering you again :)
Erm, are the modrewrite rules in the .htaccess file also used for the custom urls or only for the search engine friendly urls? That's what some test let me assume ...
I am asking because I want to implement a custom script ... and I want to reuse the url rewrite capabilites from lifetype. The urls actually look like this: blogname.foo.com/blog/
and i want blogname.foo.com/blah/ to execute my own script.
The problem is, that error.php is calling blog.php and i don't know how to check whether to include blog.php or blah.php from the error.php...

I am also wondering how lifetype knows which blog to choose if you surf to a blog via subdomain ...

Sometimes it's confusing how much code and files lifetype has :)
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel

Re: favicon per blog basis?

Postby jondaley on Tue Nov 18, 2008 11:58 pm

the modrewrite rules are only for the modrewrite version of the URLs.
Search engine friendly and custom URLs require the ForceType/SetHandler lines to make the webserver understand that post should be executed as a php document, and not a text file.

Can you make your script called blah and then add a ForceType line for blah to be executed as php?
I think it would be much hard to call it from within error.php.

The subdomain code is harder, partially due to the "multi-domain" code, if you can use LifeType's API to handle that for you, that would be easiest. Otherwise, you'll need to look at the code from class/net/http/subdomains.class.php to figure out how to get the bloginfo/id from the URL.
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: favicon per blog basis?

Postby chromos on Sat Feb 28, 2009 11:48 am

reviving this thread ...

i am now also using that template code from yours.

Did you also figure out a way to use the default favicon, when noch favicon.ico has been uploaded yet?
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel

Re: favicon per blog basis?

Postby jondaley on Sat Feb 28, 2009 6:33 pm

You could add (something like, ie. I didn't test it)
Code: Select all
RewriteCond %{REQUEST_URI} favicon.ico$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /imgs/favicon.ico


If that doesn't work straight out of the box, then you might need a .* before the first favicon.ico.
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: favicon per blog basis?

Postby chromos on Sun Mar 01, 2009 12:06 pm

works!
I love this solution! :)
I have to look into this .htaccess stuff urgently.
It looks like one is able to do nifty things with these files.
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel


Return to Requests and Suggestions

cron