<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Schnipsel - Code Schnipsel (Snippets) zu Wordpress, PHP, HTML, CSS, jQuery &#187; PHP</title>
	<atom:link href="http://schnipsel.davidhellmann.com/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://schnipsel.davidhellmann.com</link>
	<description>Code Schnipsel (Snippets) zu Wordpress, PHP, HTML, CSS, jQuery</description>
	<lastBuildDate>Tue, 08 Mar 2011 00:20:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Simple PHP Schleife</title>
		<link>http://schnipsel.davidhellmann.com/php/simple-php-schleife/66</link>
		<comments>http://schnipsel.davidhellmann.com/php/simple-php-schleife/66#comments</comments>
		<pubDate>Thu, 02 Jul 2009 13:20:31 +0000</pubDate>
		<dc:creator>David Hellmann</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[schleife]]></category>

		<guid isPermaLink="false">http://schnipsel.davidhellmann.com/php/simple-php-schleife/66</guid>
		<description><![CDATA[Kann man oft gebrauchen wenn man kleine Sachen schnell &#246;fters darstellen will. 1 2 3 &#60;?php for&#40;$i = 0; $i &#60; 10; $i++&#41; &#123; ?&#62; html code oder sonst was hier &#60;?php &#125; ?&#62;]]></description>
			<content:encoded><![CDATA[<p>
Kann man oft gebrauchen wenn man kleine Sachen schnell &#246;fters darstellen will.
</p>
<span id="more-66"></span>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	html code oder sonst was hier
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


]]></content:encoded>
			<wfw:commentRss>http://schnipsel.davidhellmann.com/php/simple-php-schleife/66/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress &#8211; Artikel anzeigen lassen (Loop)</title>
		<link>http://schnipsel.davidhellmann.com/wordpress/wordpress-artikel-anzeigen-lassen/55</link>
		<comments>http://schnipsel.davidhellmann.com/wordpress/wordpress-artikel-anzeigen-lassen/55#comments</comments>
		<pubDate>Wed, 27 May 2009 07:41:38 +0000</pubDate>
		<dc:creator>David Hellmann</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Loop]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://schnipsel.davidhellmann.com/?p=55</guid>
		<description><![CDATA[Man kann ganz einfach Artikel auch woanders anzeigen lassen. Fern von der "index.php". Mann muss nur die Kategorien angeben und die Anzahl der Beitr&#228;ge die angezeigt werden sollen. Somit kann man &#252;berall Artikel ausgeben. Zum Beispiel f&#252;r weiter Artikel in der Sidebar oder &#228;hnliches. In folgenden Beispielt w&#252;rden aus der Kategorie (1, 2, 3) 20 [...]]]></description>
			<content:encoded><![CDATA[<p>
Man kann ganz einfach Artikel auch woanders anzeigen lassen. Fern von der "<strong>index.php</strong>". Mann muss nur die Kategorien angeben und die Anzahl der Beitr&#228;ge die angezeigt werden sollen. Somit kann man &#252;berall Artikel ausgeben. Zum Beispiel f&#252;r weiter Artikel in der Sidebar oder &#228;hnliches. In folgenden Beispielt w&#252;rden aus der Kategorie (1, 2, 3) 20 Artikel angezeigt werden (insgesamt).
</p>
<span id="more-55"></span>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$myPosts</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$myPosts</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>  	
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #000088;">$my_query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cat=1,2,3&amp;showposts=20&amp;orderby=date'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
	<span style="color: #000088;">$myPosts</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;h2&gt;&lt;a id=&quot;post-<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; rel=&quot;bookmark&quot; title=&quot; <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;content&quot;&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


]]></content:encoded>
			<wfw:commentRss>http://schnipsel.davidhellmann.com/wordpress/wordpress-artikel-anzeigen-lassen/55/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Navigation f&#252;r statische Webseiten</title>
		<link>http://schnipsel.davidhellmann.com/php/navigation-fuer-statische-webseiten/44</link>
		<comments>http://schnipsel.davidhellmann.com/php/navigation-fuer-statische-webseiten/44#comments</comments>
		<pubDate>Mon, 18 May 2009 18:35:00 +0000</pubDate>
		<dc:creator>David Hellmann</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Navigation]]></category>

		<guid isPermaLink="false">http://schnipsel.davidhellmann.com/?p=44</guid>
		<description><![CDATA[Von Thomas geklaut. Eine statische Seite besteht meistens aus mehreren HTML Dateien. Bestenfalls sind es aber keine HTML Dateien sondern PHP Dateien da man dort wie der Name schon sagt PHP einsetzen kann. Man k&#246;nnte jetzt in der Navigation auf jeder Seite von Hand den aktuellen Man&#252;punkt hervorheben. Ein wenig einfacher geht das aber mittels [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Von Thomas geklaut.</strong> Eine statische Seite besteht meistens aus mehreren HTML Dateien. Bestenfalls sind es aber keine HTML Dateien sondern PHP Dateien da man dort wie der Name schon sagt PHP einsetzen kann. Man k&#246;nnte jetzt in der Navigation auf jeder Seite von Hand den aktuellen Man&#252;punkt hervorheben. Ein wenig einfacher geht das aber mittels PHP. Die Navigation wird dann in die Datei "<strong>header.php</strong>" ausgelagert und sp&#228;ter in den jeweiligen Seiten per "<strong>include</strong>" eingef&#252;gt.
</p>
<span id="more-44"></span>
<p>Als erstes gibt man jeder Datei eine kleine PHP Zeile mit, diese kommt ganz oben in die Datei und sieht wie folgt aus:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$pageID</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;startseite&quot;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'include/header.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
// In der &quot;header.php&quot; befindet sich dann die Navigation
&nbsp;
&lt;h2&gt;Startseite&lt;/h2&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin pellentesque, est ut venenatis aliquam, lorem quam porttitor ligula, eget ultrices velit dui sed quam. Praesent vehicula placerat lectus. Nulla pede. Quisque a nulla quis massa pulvinar sagittis. Pellentesque neque massa, mattis vulputate, pellentesque nec, vehicula volutpat, purus. Proin pretium dui et nulla cursus eleifend. Aenean aliquam urna eget urna. Vestibulum euismod elit. Donec eget augue sit amet neque elementum pretium. Proin posuere lacus id lacus. Duis vel justo suscipit neque ornare iaculis.&lt;/p&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'include/footer.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>



<p>Jetzt kommt die Navigation die dann wie folgt aussehen k&#246;nnte:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;ul id=&quot;navi&quot;&gt;
	&lt;li&gt;&lt;a class=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pageID</span> <span style="color: #339933;">==</span> startseite<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'aktiv'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; href=&quot;index.php&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a class=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pageID</span> <span style="color: #339933;">==</span> portfolio<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'aktiv'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; href=&quot;portfolio.php&quot;&gt;Pension&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a class=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pageID</span> <span style="color: #339933;">==</span> about<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'aktiv'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; href=&quot;about.php&quot;&gt;Mosel&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a class=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pageID</span> <span style="color: #339933;">==</span> kontakt<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'aktiv'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; href=&quot;kontakt.php&quot;&gt;Briedel&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></td></tr></table></div>



<p>Hier wird nun einfach abgefragt "Wenn pageID gleich startseite dann gebe "aktiv" aus. Somit wird nur auf der aktuellen Seite das "aktiv" ausgegeben und der Men&#252;punkt wird hervorgehoben.</p>]]></content:encoded>
			<wfw:commentRss>http://schnipsel.davidhellmann.com/php/navigation-fuer-statische-webseiten/44/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WordPress &#8211; Fehler bei deaktiviertem Plugin verhindern</title>
		<link>http://schnipsel.davidhellmann.com/wordpress/wordpress-fehler-bei-deaktiviertem-plugin-verhindern/36</link>
		<comments>http://schnipsel.davidhellmann.com/wordpress/wordpress-fehler-bei-deaktiviertem-plugin-verhindern/36#comments</comments>
		<pubDate>Wed, 13 May 2009 09:02:48 +0000</pubDate>
		<dc:creator>David Hellmann</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress Plugins]]></category>

		<guid isPermaLink="false">http://schnipsel.davidhellmann.com/?p=36</guid>
		<description><![CDATA[Von Andreas Isaak Um h&#228;ssliche Fehlermeldungen bei deaktivierten Plugins zu verhindern, bindet man dessen Funktionen mit entsprechendem Code ein. Hier wird einfach abgefragt ob das Plugin vorhanden ist. Wenn ja wird es ausgef&#252;hrt wenn nicht kommt einfach nichts. 1 2 3 &#60;?php if &#40;function_exists&#40;'pluginname'&#41;&#41; &#123; pluginname&#40;&#41;; &#125; ?&#62;]]></description>
			<content:encoded><![CDATA[<p>
Von Andreas Isaak<br /><br />
Um h&#228;ssliche Fehlermeldungen bei deaktivierten Plugins zu verhindern, bindet man dessen Funktionen mit entsprechendem Code ein. Hier wird einfach abgefragt ob das Plugin vorhanden ist. Wenn ja wird es ausgef&#252;hrt wenn nicht kommt einfach nichts.
</p>
<span id="more-36"></span>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pluginname'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
	pluginname<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>



]]></content:encoded>
			<wfw:commentRss>http://schnipsel.davidhellmann.com/wordpress/wordpress-fehler-bei-deaktiviertem-plugin-verhindern/36/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress &#8211; Automatische Weiterleitung zu einer Unterseite</title>
		<link>http://schnipsel.davidhellmann.com/wordpress/wordpress-automatische-weiterleitung-zu-einer-unterseite/35</link>
		<comments>http://schnipsel.davidhellmann.com/wordpress/wordpress-automatische-weiterleitung-zu-einer-unterseite/35#comments</comments>
		<pubDate>Wed, 13 May 2009 08:58:59 +0000</pubDate>
		<dc:creator>David Hellmann</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Weiterleitung]]></category>

		<guid isPermaLink="false">http://schnipsel.davidhellmann.com/?p=35</guid>
		<description><![CDATA[Von Andreas Isaak Jedes normale CMS bietet den Service, ein Hauptmen&#252;punkt anzulegen der dann automatisch zum ersten Untermen&#252;punkt weiterleitet. Gerade dann sinnvoll wenn man keinen Inhalt f&#252;r den Hauptmen&#252;punkt hat aber er zur Erkl&#228;rung oben stehen sollten. Leider bietet WordPress hier keine interne L&#246;sung, daher habe ich mir ein eigenes kleines Script geschrieben was in [...]]]></description>
			<content:encoded><![CDATA[<p>
Von Andreas Isaak<br /><br />
Jedes normale CMS bietet den Service, ein Hauptmen&#252;punkt anzulegen der dann automatisch zum ersten Untermen&#252;punkt weiterleitet. Gerade dann sinnvoll wenn man keinen Inhalt f&#252;r den Hauptmen&#252;punkt hat aber er zur Erkl&#228;rung oben stehen sollten.
Leider bietet WordPress hier keine interne L&#246;sung, daher habe ich mir ein eigenes kleines Script geschrieben was in die erste Zeile der header.php geh&#246;rt (noch vor dem Doctype)!
</p>
<span id="more-35"></span>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'beispielseite'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_redirect<span style="color: #009900;">&#40;</span>get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'siteurl'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/beispielseite'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>



]]></content:encoded>
			<wfw:commentRss>http://schnipsel.davidhellmann.com/wordpress/wordpress-automatische-weiterleitung-zu-einer-unterseite/35/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

