<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:series="http://unfoldingneurons.com/"
> <channel><title>Comments on: ID Your Body Using&#160;PHP</title> <atom:link href="http://davidwalsh.name/id-body-php/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/id-body-php</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Wed, 23 May 2012 04:02:29 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Jimmy B</title><link>http://davidwalsh.name/id-body-php#comment-16181</link> <dc:creator>Jimmy B</dc:creator> <pubDate>Sat, 20 Feb 2010 02:16:52 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4743#comment-16181</guid> <description>My shop is mostly Modx CMS based. Luckily Modx makes it really easy to get page specific CSS onto a specific page (or onto a page and all it&#039;s children). It&#039;s very nearly automagic.Here&#039;s how we do it:
http://wiki.modxcms.com/index.php/Dynamic_CSS_with_TVs</description> <content:encoded><![CDATA[<p>My shop is mostly Modx CMS based. Luckily Modx makes it really easy to get page specific CSS onto a specific page (or onto a page and all it&#8217;s children). It&#8217;s very nearly automagic.</p><p>Here&#8217;s how we do it:<br
/> <a
href="http://wiki.modxcms.com/index.php/Dynamic_CSS_with_TVs" rel="nofollow">http://wiki.modxcms.com/index.php/Dynamic_CSS_with_TVs</a></p> ]]></content:encoded> </item> <item><title>By: Bam Roberts</title><link>http://davidwalsh.name/id-body-php#comment-15964</link> <dc:creator>Bam Roberts</dc:creator> <pubDate>Fri, 05 Feb 2010 17:06:29 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4743#comment-15964</guid> <description>@Bam Roberts:
oops, lost my body tag in the ctrl-c ctrl-v ing.I end up with
&lt;body id=&quot;shop-lenses-canon-50mm-f14-details&quot; class=&quot;shop lenses canon 50mm-f14 details”&gt;</description> <content:encoded><![CDATA[<p>@Bam Roberts:<br
/> oops, lost my body tag in the ctrl-c ctrl-v ing.</p><p>I end up with<br
/> &lt;body id=&#8221;shop-lenses-canon-50mm-f14-details&#8221; class=&#8221;shop lenses canon 50mm-f14 details”&gt;</p> ]]></content:encoded> </item> <item><title>By: Bam Roberts</title><link>http://davidwalsh.name/id-body-php#comment-15958</link> <dc:creator>Bam Roberts</dc:creator> <pubDate>Fri, 05 Feb 2010 10:31:50 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4743#comment-15958</guid> <description>Hi David,Good post, I been using something similar to this in my frame work, but i split the sections into an array and then pop them one at a time into the class name.If I have the url www.mysite.com/shop/lenses/canon/50mm-f1.4/details/ i end up with  this lets me style by all sorts of extra variables, like having canon specific branding, department background images and differing icons.With CSS3 you can also write body.lenses.details{...} for even more granular control.</description> <content:encoded><![CDATA[<p>Hi David,</p><p>Good post, I been using something similar to this in my frame work, but i split the sections into an array and then pop them one at a time into the class name.</p><p>If I have the url <a
href="http://www.mysite.com/shop/lenses/canon/50mm-f1.4/details/" rel="nofollow">http://www.mysite.com/shop/lenses/canon/50mm-f1.4/details/</a> i end up with  this lets me style by all sorts of extra variables, like having canon specific branding, department background images and differing icons.</p><p>With CSS3 you can also write body.lenses.details{&#8230;} for even more granular control.</p> ]]></content:encoded> </item> <item><title>By: seelts</title><link>http://davidwalsh.name/id-body-php#comment-15949</link> <dc:creator>seelts</dc:creator> <pubDate>Fri, 05 Feb 2010 07:38:58 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4743#comment-15949</guid> <description>&quot;
function generate_id($uri)
{
...
return preg_replace(
array($regex1,$regex2,$regex3,$regex4),
array(&#039;-&#039;,&#039;-&#039;,&#039;&#039;,&#039;&#039;),
$_SERVER[&#039;REQUEST_URI&#039;]
);
}
&quot;
it will be more logical to use $uri instead $_SERVER[&#039;REQUEST_URI&#039;] in preg_replace() or remove it completely from the arguments list of a generate_id function to ba able to write &quot;$body_id = generate_id();&quot;but it was an offtopic... now question!
as i&#039;ve understood, you use it to be able to apply different styles, depending of what page is loaded. does it mean that you give to user a css that has all styles for all possible body ids?
doesn&#039;t it perversion? it seems to be easier (and &quot;natural&quot; may be) to generate necessary style sheet or to choose what css will be included before giving it to user.</description> <content:encoded><![CDATA[<p>&#8221;<br
/> function generate_id($uri)<br
/> {<br
/> &#8230;<br
/> return preg_replace(<br
/> array($regex1,$regex2,$regex3,$regex4),<br
/> array(&#8216;-&#8217;,'-&#8217;,&#8221;,&#8221;),<br
/> $_SERVER['REQUEST_URI']<br
/> );<br
/> }<br
/> &#8221;<br
/> it will be more logical to use $uri instead $_SERVER['REQUEST_URI'] in preg_replace() or remove it completely from the arguments list of a generate_id function to ba able to write &#8220;$body_id = generate_id();&#8221;</p><p>but it was an offtopic&#8230; now question!<br
/> as i&#8217;ve understood, you use it to be able to apply different styles, depending of what page is loaded. does it mean that you give to user a css that has all styles for all possible body ids?<br
/> doesn&#8217;t it perversion? it seems to be easier (and &#8220;natural&#8221; may be) to generate necessary style sheet or to choose what css will be included before giving it to user.</p> ]]></content:encoded> </item> <item><title>By: Mullanaphy!</title><link>http://davidwalsh.name/id-body-php#comment-15940</link> <dc:creator>Mullanaphy!</dc:creator> <pubDate>Thu, 04 Feb 2010 23:33:36 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4743#comment-15940</guid> <description>Interesting. Think I might adopt a method out of this, utilizing either the name of the page&#039;s Class name if it&#039;s PHP or Package name if it&#039;s Perl. Could also look at using it via Namespace::Class (namespace_class).Very intriguing. You site motivates me to continue developing a programming help blog.</description> <content:encoded><![CDATA[<p>Interesting. Think I might adopt a method out of this, utilizing either the name of the page&#8217;s Class name if it&#8217;s PHP or Package name if it&#8217;s Perl. Could also look at using it via Namespace::Class (namespace_class).</p><p>Very intriguing. You site motivates me to continue developing a programming help blog.</p> ]]></content:encoded> </item> <item><title>By: David Radcliffe</title><link>http://davidwalsh.name/id-body-php#comment-15923</link> <dc:creator>David Radcliffe</dc:creator> <pubDate>Thu, 04 Feb 2010 13:12:42 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4743#comment-15923</guid> <description>Nice post, great idea. Looks like your very last example is missing the generate_id() function call.</description> <content:encoded><![CDATA[<p>Nice post, great idea. Looks like your very last example is missing the generate_id() function call.</p> ]]></content:encoded> </item> <item><title>By: Mattias Wirf</title><link>http://davidwalsh.name/id-body-php#comment-15911</link> <dc:creator>Mattias Wirf</dc:creator> <pubDate>Thu, 04 Feb 2010 05:25:20 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4743#comment-15911</guid> <description>Wordpress does that thing with post-ID but I almost never used it in CSS, becuase I want to write the page/post without changing the CSS every time.
But I guess it would come in use on the body of a page. Hm, I would use the pagename probably, to make it shorter without dirs.</description> <content:encoded><![CDATA[<p>WordPress does that thing with post-ID but I almost never used it in CSS, becuase I want to write the page/post without changing the CSS every time.<br
/> But I guess it would come in use on the body of a page. Hm, I would use the pagename probably, to make it shorter without dirs.</p> ]]></content:encoded> </item> <item><title>By: Aeron</title><link>http://davidwalsh.name/id-body-php#comment-15908</link> <dc:creator>Aeron</dc:creator> <pubDate>Wed, 03 Feb 2010 21:06:25 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4743#comment-15908</guid> <description>@DerrickCheck the kilas&#039;s regexp: /[^0-9a-z]{1,}/ - could also be written as /[^0-9a-z]+/ - which means &quot;one or more&quot; instances of a match are written as a single dash. So... same thing...If we&#039;re comparing functions to generate slugs... I like the one from Cake - which also handles special characters gracefully:http://api.cakephp.org/view_source/inflector/#line-493I&#039;ve re-written it for Javascript (had to encode the special characters to avoid problems with YUI compressor):http://pastebin.com/f4cd741a0And even Coldfusion (if you like pain):http://pastebin.com/f597de5ad</description> <content:encoded><![CDATA[<p>@Derrick</p><p>Check the kilas&#8217;s regexp: /[^0-9a-z]{1,}/ &#8211; could also be written as /[^0-9a-z]+/ &#8211; which means &#8220;one or more&#8221; instances of a match are written as a single dash. So&#8230; same thing&#8230;</p><p>If we&#8217;re comparing functions to generate slugs&#8230; I like the one from Cake &#8211; which also handles special characters gracefully:</p><p><a
href="http://api.cakephp.org/view_source/inflector/#line-493" rel="nofollow">http://api.cakephp.org/view_source/inflector/#line-493</a></p><p>I&#8217;ve re-written it for Javascript (had to encode the special characters to avoid problems with YUI compressor):</p><p><a
href="http://pastebin.com/f4cd741a0" rel="nofollow">http://pastebin.com/f4cd741a0</a></p><p>And even Coldfusion (if you like pain):</p><p><a
href="http://pastebin.com/f597de5ad" rel="nofollow">http://pastebin.com/f597de5ad</a></p> ]]></content:encoded> </item> <item><title>By: kilas</title><link>http://davidwalsh.name/id-body-php#comment-15907</link> <dc:creator>kilas</dc:creator> <pubDate>Wed, 03 Feb 2010 20:47:57 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4743#comment-15907</guid> <description>@Derrick Nelson:  Hmm.. I dont understand. Check this:My method:
Filename: ----1_d-------rzewo&#039;-----.php
Result: mashup-1-d-rzewo-phpby David:
Filename: ----1_d-------rzewo&#039;-----.php
Result: mashup-1-d-rzewo-phpGive some examples.</description> <content:encoded><![CDATA[<p>@Derrick Nelson:  Hmm.. I dont understand. Check this:</p><p>My method:<br
/> Filename: &#8212;-1_d&#8212;&#8212;-rzewo&#8217;&#8212;&#8211;.php<br
/> Result: mashup-1-d-rzewo-php</p><p>by David:<br
/> Filename: &#8212;-1_d&#8212;&#8212;-rzewo&#8217;&#8212;&#8211;.php<br
/> Result: mashup-1-d-rzewo-php</p><p>Give some examples.</p> ]]></content:encoded> </item> <item><title>By: Aeron Glemann</title><link>http://davidwalsh.name/id-body-php#comment-15906</link> <dc:creator>Aeron Glemann</dc:creator> <pubDate>Wed, 03 Feb 2010 18:41:18 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4743#comment-15906</guid> <description>I had to do something like this on a recent project. Only thing is I needed a more versatile solution. For example, what if you want your CSS from one page to inherit from another page. You can do that with ID&#039;s if you have one ID nested inside another. But you can&#039;t have one BODY tag nested inside another, so I went with DIVs. This also let&#039;s me load one page within another (for example, loading into a modal window) and preserve all the styles of the original page - so long as all relevant styles target the ID&#039;s. If you also use the ID&#039;s to target Javascript behavior same thing - load a page into another page and preserve all original behavior. Anyway, result is here - worked well so far: http://www.cafebritt.com</description> <content:encoded><![CDATA[<p>I had to do something like this on a recent project. Only thing is I needed a more versatile solution. For example, what if you want your CSS from one page to inherit from another page. You can do that with ID&#8217;s if you have one ID nested inside another. But you can&#8217;t have one BODY tag nested inside another, so I went with DIVs. This also let&#8217;s me load one page within another (for example, loading into a modal window) and preserve all the styles of the original page &#8211; so long as all relevant styles target the ID&#8217;s. If you also use the ID&#8217;s to target Javascript behavior same thing &#8211; load a page into another page and preserve all original behavior. Anyway, result is here &#8211; worked well so far: <a
href="http://www.cafebritt.com" rel="nofollow">http://www.cafebritt.com</a></p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 3/7 queries in 0.006 seconds using disk: basic
Object Caching 805/805 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-23 03:20:43 -->
