<?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>Ordo Ab Chao - Il blog di Rocco Agostino &#187; how-to</title>
	<atom:link href="http://blog.roccoagostino.eu/tag/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.roccoagostino.eu</link>
	<description>Il mio blog personale in cui si discute di libri,musica,scrittura,poesia,video,foto,news,attualità,informatica e tecnologia. Un &#34;corner&#34; da condividere con voi che commentate,criticate o apprezzate.</description>
	<lastBuildDate>Fri, 18 Nov 2011 05:48:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<atom:link rel='hub' href='http://blog.roccoagostino.eu/?pushpress=hub'/>
		<item>
		<title>Personalizzare i commenti nidificati in WordPress</title>
		<link>http://blog.roccoagostino.eu/2011/11/06/personalizzare-i-commenti-nidificati-in-wordpress/</link>
		<comments>http://blog.roccoagostino.eu/2011/11/06/personalizzare-i-commenti-nidificati-in-wordpress/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 05:55:36 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[funzioni]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[thumbnail]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=910</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/>WordPress dalla versione 2.7 supporta il threading dei commenti, ovvero l’incapsulamento di tutte le discussioni di un articolo. Il tag wp_list_comments() si prende carico della gestione delle liste nidificate, delle classi associate ad ogni livello di commento, di predisporre i link giusti e di recuperare i contenuti dei commenti. Il problema nasce quando si vuole personalizzare la modalità di visualizzazione dei commenti. In questo caso è necessario utilizzare l'opzione di callback che viene fornito nella lista degli argomenti di wp_list_comments().]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/><p>WordPress dalla versione 2.7 supporta il threading dei commenti, ovvero l’incapsulamento di tutte le discussioni di un articolo. Il tag <em>wp_list_comments()</em> si prende carico della gestione delle liste nidificate, delle classi associate ad ogni livello di commento, di predisporre i link giusti e di recuperare i contenuti dei commenti. Il problema nasce quando si vuole personalizzare la modalità di visualizzazione dei commenti. In questo caso è necessario utilizzare l&#8217;opzione di callback che viene fornito nella lista degli argomenti di <em>wp_list_comments()</em>.</p>
<p><span id="more-910"></span></p>
<p>Un callback è un&#8217;istruzione per eseguire un&#8217;altra funzione definita. Nel nostro caso la useremo per personalizzare il codice HTML dei commenti, pur mantenendo la possibilità di utilizzare il threading.<br />
&nbsp;</p>
<h1>Definiamo il callback</h1>
<p>&nbsp;<br />
Per prima cosa definiamo la nostra funzione di callback ed inseriamola nel file <em>function.php</em> (ovviamente ricordatevi si fare una copia di backup).<br />
&nbsp;</p>

<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
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">function miotema_comment($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment;
?&gt;
	&lt;li <span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_class<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> id=&quot;li-comment-<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
		&lt;div id=&quot;comment-<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_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;&gt;
			&lt;div class=&quot;comment-author vcard&quot;&gt;
				<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> get_avatar<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_author_email</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">48</span> <span style="color: #009900;">&#41;</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: #990000;">printf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;cite class=&quot;fn&quot;&gt;%s&lt;/cite&gt; &lt;span class=&quot;says&quot;&gt;says:&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> get_comment_author_link<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</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;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_approved</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				&lt;em&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Il tuo commento è in attesa di moderazione.'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/em&gt;
				&lt;br /&gt;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
			&lt;div class=&quot;comment-meta commentmetadata&quot;&gt;
				&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span> get_comment_link<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_ID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%1$s at %2$s'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> get_comment_date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>  get_comment_time<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;
				<span style="color: #000000; font-weight: bold;">&lt;?php</span> edit_comment_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'(Edit)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'  '</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;/div&gt;
                        &lt;/br&gt;&lt;/br&gt;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_text<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;div class=&quot;reply&quot;&gt;
				<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_reply_link<span style="color: #009900;">&#40;</span><span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'depth'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$depth</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'max_depth'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max_depth'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;/div&gt;
		&lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>&nbsp;<br />
Vediamo quale funzione entra in gioco.<br />
&nbsp;<br />
<span style="color: #ff0000;"><em>comment_class()</em></span><br />
Questa funzione crea un elenco di classi come class = &#8220;classe1 class2 class3&#8243; per identificare i commenti pari/dispari, la profondità attuale dei commenti o altro.<br />
&nbsp;<br />
<span style="color: #ff0000;"><em>comment_ID()</em></span><br />
L&#8217;ID è il numero univoco del commento in corso.<br />
&nbsp;<br />
<span style="color: #ff0000;"><em>get_avatar()</em></span><br />
Utilizza l&#8217;e-mail per associare un gravatar. Primo parametro deve essere l&#8217;oggetto $ comment, il secondo è il formato per l&#8217;avatar, l&#8217;ultimo è l&#8217;URL di un avatar di default (deve essere URL completo).<br />
&nbsp;<br />
<span style="color: #ff0000;"><em>get_comment_link()</em></span><br />
Ottiene il link al commento in corso.<br />
&nbsp;<br />
<span style="color: #ff0000;">edit_comment_link()</span><br />
Ottiene il link per modificare il commento corrente.<br />
&nbsp;<br />
<span style="color: #ff0000;"><em>comment_text()</em></span><br />
Ottiene il testo del il commento in corso.<br />
&nbsp;<br />
<span style="color: #ff0000;"><em>comment_reply_link()</em></span><br />
Ottiene il link per rispondere al commento in corso.<br />
&nbsp;</p>
<h1>Agganciamo la nostra funzione</h1>
<p>&nbsp;<br />
Il layout che andiamo a ridefinire è quello generato proprio da <em>wp_list_comments()</em>. Per fare ciò è sufficiente fornire il parametro “callback=nome_funzione” per indicare a WordPress di ignorare il normale comportamento della funzione e utilizzare invece una nostra versione personalizzata.<br />
&nbsp;<br />
Nel nostro file comments.php andiamo dunque a modificare <em>wp_list_comments()</em> in questo modo:<br />
&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">wp_list_comments <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'callback=miotema_comment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&nbsp;<br />
Ovviamente è possibile utilizzare un foglio di stile CSS per rendere i commenti gradevoli da vedere:  per esempio io ho utilizzato <a title="CSS Triangle Arrow DIVs" href="http://www.dynamicdrive.com/style/csslibrary/item/css_triangle_arrow_divs/" target="_blank">questo metodo</a> e questo è il risultato:<br />
&nbsp;<br />
<a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/11/commenti.png"><img class="aligncenter size-full wp-image-911" title="commenti" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/11/commenti.png" alt="" width="500" height="522" /></a><br />
&nbsp;<br />
<strong>Tutto qui. Come sempre lasciate dei commenti o magari mandatemi una e-mail. Anche eventuali suggerimenti o consigli sono sempre graditi.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2011/11/06/personalizzare-i-commenti-nidificati-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thumbnails per WordPress.com Popular Posts</title>
		<link>http://blog.roccoagostino.eu/2011/10/23/thumbnails-per-wordpress-com-popular-posts/</link>
		<comments>http://blog.roccoagostino.eu/2011/10/23/thumbnails-per-wordpress-com-popular-posts/#comments</comments>
		<pubDate>Sun, 23 Oct 2011 17:49:58 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[In evidenza]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Sviluppo WEB]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[funzioni]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[thumbnail]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[WordPress.com Popular Posts]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=829</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/css_ico.JPG" width="32" height="32" alt="" title="Sviluppo WEB" /><img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/>Modifica del plugin WordPress.com Popular Posts per inserire nella lista degli articoli più popolari, la thumbnail associata al post.]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/css_ico.JPG" width="32" height="32" alt="" title="Sviluppo WEB" /><img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/><p>Per la visualizazione degli articoli più popolari uso il plugin <a href="http://wordpress.org/extend/plugins/wordpress-popular-posts/" target="_blank">WordPress.com Popular Post</a>. Tale plugin permette molte personalizzazioni, ma manca la possibilità di poter visualizzare le immagini riferite ai post. L&#8217;idea di fondo parte da <a href="http://www.geoffblog.com/2010/07/thumbnails-for-wordpresscom-popular.html" target="_blank">questo articolo</a> che spiega come aggiungere delle immagini all&#8217;elenco dei post con l&#8217;ausilio di uno script esterno. Senza utilizzare script esterni, possiamo, invece, sfruttare le <a href="http://blog.roccoagostino.eu/2011/10/06/modificare-il-tema-di-wordpress-parte-1-la-funzione-post-thumbnail/" target="_blank">nuove features</a> di WordPress 3.x.<br />
<span id="more-829"></span><br />
Nel momento in cui vogliamo il percorso dell&#8217;immagine associata al post il programma procederà in questo modo:</p>
<ul>
<li>cerca la thumbnail associata al post;</li>
<li>nel caso in cui il tema non supporti tale funzione o non si è inserita in fase di creazione del post, cerca la prima immagine nel post;</li>
<li>nel caso in cui il post non abbia neanche una immagine, me associa una di default.</li>
</ul>
<p>&nbsp;</p>
<p>Vediamo come:</p>
<p>&nbsp;</p>
<h1>1) Modifica del plugin</h1>
<p>&nbsp;</p>
<p>Andando in Plugin-&gt;Editor selezioniamo il plugin WPPP e quindi il file <em>wppp.php</em>.</p>
<p>&nbsp;</p>
<p>Per prima cosa troviamo il codice:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Replace format with data</span>
<span style="color: #000088;">$replace</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'%post_permalink%'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> get_permalink<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_id'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'%post_title%'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> esc_html<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>truncateText<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title_length'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'%post_title_attribute%'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> esc_attr<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_title'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'%post_views%'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> number_format_i18n<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'views'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>e aggiungiamo la seguente riga:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$replace</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'%post_thumb%'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span>return_post_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>A questo punto dobbiamo inserire la funzione <em>return_post_image</em>.</p>
<p>&nbsp;</p>
<h1>2) Modifica del file function.php</h1>
<p>&nbsp;</p>
<p>Nel file <em>function.php</em> aggiungiamo:</p>
<p>&nbsp;</p>

<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
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
* Capture the first image from the post.
* @global object $post
* @global object $posts
* @return string
*/</span>
<span style="color: #000000; font-weight: bold;">function</span> theme_function_capture_first_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$firstImg</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">,</span> <span style="color: #000088;">$posts</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$firstImg</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #990000;">ob_end_clean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'//i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>post_content<span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$firstImg</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'//i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$p</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>post_content<span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$firstImg</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$firstImg</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ritorna una immagine associata al post: thumb, prima immagine del post, default</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> return_post_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">,</span><span style="color: #000088;">$dim</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$imgpath</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dim</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$dim</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$imgpath</span><span style="color: #339933;">=</span>get_the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dim</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: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imgpath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$imgpath</span> <span style="color: #339933;">=</span> theme_function_capture_first_image<span style="color: #009900;">&#40;</span>get_post<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</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: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imgpath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$imgpath</span> <span style="color: #339933;">=</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_directory'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/images/default_pp.gif'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$imgpath</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;img src=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$imgpath</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; alt=&quot;'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$title</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$imgpath</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>N.B.: Di default la dimensione dell&#8217;imamgine è di 60&#215;60. Nel caso in cui noi volessimo una immagine di dimensione diversa, per esempio 32&#215;32, basta modificare la chiamata alla funzione nel file <em>wppp.php</em> in questo modo:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">replace<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'%post_thumb%'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span>return_post_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">32</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">32</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Un&#8217;altra modifica, in futuro, potrebbe essere fare in modo di passare la dimensione dei thumbs nel momento in cui viene richiamato il plugin.</p>
<p>&nbsp;</p>
<p>A questo punto quando richiamiamo il plugin avremo a possibilità di inserire il tag %post_thumb% che ci darà l&#8217;&lt;img&gt; riferita all&#8217;immagine associata al post.</p>
<p>&nbsp;</p>
<h1>3) il CSS per lo stile</h1>
<p>&nbsp;</p>
<p>Concludiamo con il css per lo stile dell&#8217;elenco dei post, che nel mio caso è:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*Popular Posts*/</span>
&nbsp;
ul<span style="color: #6666ff;">.wppp_list</span> li <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">65px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span> <span style="color: #993333;">outside</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul<span style="color: #6666ff;">.wppp_list</span> img <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">4px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ECEFF5</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Ed ecco il risultato finale:<br />
<a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/ppp.png"><img class="aligncenter size-full wp-image-831" title="ppp" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/ppp.png" alt="" width="378" height="473" /></a></p>
<p>&nbsp;</p>
<p><strong>Enjoy it!</strong></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2011/10/23/thumbnails-per-wordpress-com-popular-posts/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Modificare il tema di WordPress (parte 3): personalizzare l&#8217;intestazione e lo sfondo</title>
		<link>http://blog.roccoagostino.eu/2011/10/17/modificare-il-tema-di-wordpress-parte-3-personalizzare-lintestazione-e-lo-sfondo/</link>
		<comments>http://blog.roccoagostino.eu/2011/10/17/modificare-il-tema-di-wordpress-parte-3-personalizzare-lintestazione-e-lo-sfondo/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 17:16:26 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[funzioni]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[sfondo]]></category>
		<category><![CDATA[testata]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=760</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/>Aggiornando la piattaforma alla versione 3.x di Wordpress, il tema che avete installato precedentemente sicuramente non conterrà le nuove funzioni di personalizzazione dell'intestazione e dello sfondo del blog. Grazie a semplici modifiche ai files del tema è possibile inserire, lato pannello di amministrazione, queste funzioni in modo da modificare l'aspetto del blog senza dover agire sul codice del tema stesso.]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/><p>Aggiornando la piattaforma alla versione 3.x di WordPress, il tema che avete installato precedentemente sicuramente non conterrà le nuove funzioni di personalizzazione dell&#8217;intestazione e dello sfondo del blog. Grazie a semplici modifiche ai files del tema è possibile inserire, lato pannello di amministrazione, queste funzioni in modo da modificare l&#8217;aspetto del blog senza dover agire sul codice del tema stesso.</p>
<p><span id="more-760"></span></p>
<p>&nbsp;</p>
<h1>la Testata</h1>
<p>Tra le novità di WordPress 3.x vi è il pannello per la personalizzazione delle intestazioni. E&#8217; possibile accedere alle intestazioni personalizzate abilitando la voce nel pannello di amministrazione di WordPress 3.x anche se il vostro tema non lo supporta nativamente.<br />
Per fare ciò basta inserire nel file <em>function.php</em> le seguenti linee di codice:</p>
<p>&nbsp;</p>

<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
17
18
19
20
21
22
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">define( 'HEADER_IMAGE', '%s/images/logo.jpj' ); //logo di defaul
define( 'HEADER_IMAGE_WIDTH', apply_filters( '', 948 ) ); // Larghezza del logo
define( 'HEADER_IMAGE_HEIGHT', apply_filters( '', 180 ) ); // Altezza del logo
define( 'NO_HEADER_TEXT', true );
add_custom_image_header( '', 'admin_header_style' ); // Abilita la voce nel pannello di controllo 
&nbsp;
// Foglio di stile per il pannello amministratore
if ( ! function_exists( 'admin_header_style' ) ) :
function admin_header_style() {
?&gt;
&lt;style type=&quot;text/css&quot;&gt;
#headimg {
height: <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> HEADER_IMAGE_HEIGHT<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>px;
width: <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> HEADER_IMAGE_WIDTH<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>px;
}
#headimg h1, #headimg #desc {
display: none;
}
&lt;/style&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Nel pannelo di controllo nel menu &#8220;aspetto&#8221; comparirà la voce &#8220;Testata&#8221;.</p>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/aspetto_testa.jpg"><img class="aligncenter size-full wp-image-761" style="border-width: 1px; border-color: black; border-style: solid;" title="aspetto_testa" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/aspetto_testa.jpg" alt="" width="166" height="168" /></a></p>
<p>&nbsp;</p>
<p>Selezionandola, comparirà la nuova pagina di amministrazione per la scelta delle immagini da inserire nell&#8217;header del blog.<br />
Una volta caricate le immagini possiamo anche decidere di visualizzarle in maniera random.</p>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/testata_personalizzazione.jpg"><img class="aligncenter size-full wp-image-764" style="border-width: 1px; border-color: black; border-style: solid;" title="testata_personalizzazione" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/testata_personalizzazione.jpg" alt="" width="540" height="568" /></a></p>
<p>&nbsp;</p>
<p>Nel <em>header.php</em> basta inserire la seguente linea di codice:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> header_image<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; width=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> HEADER_IMAGE_WIDTH<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; height=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> HEADER_IMAGE_HEIGHT<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; alt=&quot;&quot; /&gt;</pre></td></tr></table></div>

<p>o anche</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;div id=&quot;header-container&quot; style=&quot;background: url('<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> header_image<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;</pre></td></tr></table></div>

<p>&nbsp;</p>
<h1>lo Sfondo</h1>
<p>Altra modifica possibile per utilizzare le nuove funzioni di WordPress 3.x è la possibilità di personalizza lo sfondo</p>
<p>&nbsp;</p>
<p>Aggiungendo nel file <em>function.php</em> la linea di codice:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">add_custom_background<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p style="text-align: center;">nel pannello di amministrazione comparirà la voce &#8220;Sfondo&#8221; nel menù &#8220;Aspetto&#8221;:<br />
<a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/aspetto_sfondo.jpg"><img class="aligncenter size-full wp-image-780" style="border-width: 1px; border-color: black; border-style: solid;" title="aspetto_sfondo" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/aspetto_sfondo.jpg" alt="" width="166" height="168" /></a><br />
Selezionandola, comparirà la nuova pagina di amministrazione per la scelta dello sfondo da inserire nel blog.</p>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/sfondo_personalizzazione.jpg"><img class="aligncenter size-full wp-image-767" style="border-width: 1px; border-color: black; border-style: solid;" title="sfondo_personalizzazione" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/sfondo_personalizzazione.jpg" alt="" width="540" height="662" /></a></p>
<p>&nbsp;</p>
<p><strong>Enjoy it and.. see you soon!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2011/10/17/modificare-il-tema-di-wordpress-parte-3-personalizzare-lintestazione-e-lo-sfondo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modificare il tema di WordPress (parte 2): menù di navigazione</title>
		<link>http://blog.roccoagostino.eu/2011/10/08/modificare-il-tema-di-wordpress-parte-2-menu-di-navigazione/</link>
		<comments>http://blog.roccoagostino.eu/2011/10/08/modificare-il-tema-di-wordpress-parte-2-menu-di-navigazione/#comments</comments>
		<pubDate>Sat, 08 Oct 2011 21:04:17 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[funzioni]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=669</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/>Modificare il tema di Wordpress per poter utilizzare il menù di navigazione.]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/><p>WordPress include un meccanismo semplice per introdurre dei menù di navigazione personalizzati nel proprio tema. Per incorporare nel tema il supporto al menù, è necessario aggiungere poche righe di codice. Innanzitutto nel file <em>functions.php</em> del tema, si deve scrivere una funzione per registrare il nome dei menù che si vogliono creare. Il nome sarà quello che comparirà nella pagina del pannello di amministrazione di WordPress alla pagina Aspetto-&gt;Menu.<br />
<span id="more-669"></span><br />
Per esempio, tramite questo codice, nel box “Posizione dei temi” comparirà la posizione “Menu Intestazione”:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> register_my_menus<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  register_nav_menus<span style="color: #009900;">&#40;</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'menu-intestazione'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Menu Intestazione'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>questo codice, invece, farà comparire due nuove posizioni:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> register_my_menus<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
register_nav_menus<span style="color: #009900;">&#40;</span>
  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'menu-intestazione'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Menu Intestazione'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'menu-extra'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Menu Extra'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Per assicurarsi che il tema attivi l’opzione dei menù personalizzati, è necessario aggiungere anche questa riga che comunica al tema di eseguire la funzione “<em>register_my_menus</em>”:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'register_my_menus'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>A questo punto resta da inserire nel tema la posizione in cui vogliamo che il menù (o i vari menù) siano visualizzati. Per far questo si deve aprire nell’editor il file del template corrispondente alla posizione desiderata e inserire una chiamata alla funzione <em>wp_nav_menu()</em> per ciascuna posizione. Per esempio, si vuole posizionare il menu “Menu Intestazione”, precedentemente registrato nel file <em>header.php</em>, in modo che compaia nella testata del tema. Il codice da inserire è il seguente:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_nav_menu<span style="color: #009900;">&#40;</span>  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'theme_location'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'menu-intestazione'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>IMPORTANTE: il nome associato a theme_location deve essere lo stesso inserito in <em>functions.php</em>.</strong></p>
<p>&nbsp;</p>
<p>Questa funzione crea una lista del tipo</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;ul&gt; 
  &lt;li&gt;&lt;/li&gt;
  &lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></div></div>

<p>Se si aggiunge alla funzione <em>wp_nav_menu()</em> il parametro “<em>container_class</em>”, si può specificare la classe associata al menù:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_nav_menu<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'theme_location'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'menu-intestazione'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'container_class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'classe_menu_intestazione'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>In questo modo si può personalizzare la grafica del menù specificando nel CSS gli attributi della classe “classe_menu_intestazione”.</p>
<p>Oppure, come nel mio caso, se già esiste nel foglio di stile una classe per i menù tradizionali, basta sostituire il codice all&#8217;interno, per esempio, del</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=”menu”&gt;......&lt;/div&gt;</pre></div></div>

<p>richiamando la funzione</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_nav_menu<span style="color: #009900;">&#40;</span>  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'theme_location'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'menu-intestazione'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Enjoy it and.. see you soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2011/10/08/modificare-il-tema-di-wordpress-parte-2-menu-di-navigazione/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modificare il tema di WordPress (parte 1): la funzione post thumbnail</title>
		<link>http://blog.roccoagostino.eu/2011/10/06/modificare-il-tema-di-wordpress-parte-1-la-funzione-post-thumbnail/</link>
		<comments>http://blog.roccoagostino.eu/2011/10/06/modificare-il-tema-di-wordpress-parte-1-la-funzione-post-thumbnail/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 18:34:49 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[funzioni]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[thumbnail]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=625</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/>Come inserire nel proprio tema funzione post thumbnail (miniature) per associare una immagine agli articoli.]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/><p>Ormai del mio tema per wordpress, che ho scaricato tra quelli gratuiti nel lontano 2009, ci sta ben poco. Nel corso dei mesi tante sono state le modifiche: supporto ai plugin, ai widget, agli script in JQuery, modifiche in php che adesso ad elencarli tutti ho davvero tanta difficoltà. Wordpress si aggiorna, introduce nuove funzioni e nuove possibilità di fare blogging, ma il mio tema &#8220;no, non lo voglio cambiare!&#8221;.</p>
<p><span id="more-625"></span></p>
<p>Così, armato di santa pazienza, googlando un pò in giro, ecco che mi ritrovo per l&#8217;ennesima volta a far modifiche.</p>
<p>&nbsp;</p>
<p>Vediamo la prima: la funzione post thumbnail (miniature).</p>
<p>&nbsp;</p>
<p>Le icone che vedere associate agli articoli di questo blog sono in realtà associate alle categorie (uso il plugin <a href="http://blog.roccoagostino.eu/2009/08/30/associa-le-icone-alle-categorie-del-blog-wordpresscategory-icons-plugin/" target="_blank">Category Icons</a>). Pertanto esse non sono direttamente legate al contenuto dell&#8217;articolo. Stanco della visualizzazione testuale a lista dei post correlati ho installato il plugin <a href="http://wordpress.org/extend/plugins/related-posts-thumbnails/" target="_blank">Related Posts Thumbnails</a> che crea un riquadro per ogni articolo correlato inserendo una immagine contenuta nell&#8217;articolo stesso. Problema: e se nel contenuto non vi sono inserite delle immagini? Il plugin usa la minitura associata all&#8217;articolo!</p>
<p>&nbsp;</p>
<p>Per attivare la gestione lato backend della “miniatura articolo” è sufficiente editare il file <em>functions.php</em> e inserire le seguenti linee di codice che, nell&#8217;ottica di compatibilità e stabilità, sono:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><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;">'add_theme_support'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    add_theme_support<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post-thumbnails'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>&nbsp;</p>
<p>Fatto questo, entrando nell’amministrazione e andando nella modifica di un post, troveremo sulla sidebar destra un nuovo pannello:</p>
<p>&nbsp;</p>
<p><center><img class="aligncenter size-full wp-image-617" title="thumbs" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/thumbs.jpg" alt="" width="295" height="76" /></center>Da qui possiamo associare una immagine all&#8217;articolo.</p>
<p>&nbsp;</p>
<p>Con</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;!--</span>?php get_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>?<span style="color: #339933;">--&gt;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>recuperiamo l’url della nostra thumbnail e possiamo tranquillamente inserirlo nel loop in questo modo ad esempio:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;div&gt;&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_post_thumbnail<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; alt=&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;&lt;/div&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Enjoy it and.. see you soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2011/10/06/modificare-il-tema-di-wordpress-parte-1-la-funzione-post-thumbnail/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>StereoVisione con OpenCV, QT4, openGL</title>
		<link>http://blog.roccoagostino.eu/2011/09/22/stereovisione-con-opencv/</link>
		<comments>http://blog.roccoagostino.eu/2011/09/22/stereovisione-con-opencv/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 13:56:57 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[openGL]]></category>
		<category><![CDATA[QT4]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[programmazione]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=468</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/12/opencv-logo_p.jpg" width="32" height="32" alt="" title="OpenCV" /><img src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/09/opengl_p.png" width="32" height="32" alt="" title="openGL" /><img src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/12/Qt4logo_p.jpg" width="32" height="32" alt="" title="QT4" /><br/>La Stereovisione o StereoscopiaW è una tecnica di realizzazione e visione di immagini, disegni, fotografie e filmati, finalizzata a trasmettere una illusione di tridimensionalità, analoga a quella generata dalla visione binoculare del sistema visivo umano. La visione stereoscopica consente di inferire la struttura tridimensionale di una scena osservata da due o piu’ telecamere (nel caso di due telecamere [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/12/opencv-logo_p.jpg" width="32" height="32" alt="" title="OpenCV" /><img src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/09/opengl_p.png" width="32" height="32" alt="" title="openGL" /><img src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/12/Qt4logo_p.jpg" width="32" height="32" alt="" title="QT4" /><br/><p style="text-align: justify;">La Stereovisione o <a href="http://it.wikipedia.org/wiki/Stereoscopia" rel="nofollow" target="_blank" title="Da Wikipedia la definizione di: Stereoscopia" style="padding-bottom: 2px; border-bottom: 1px dotted #DD0000" >Stereoscopia</a><sup style="font-family: Georgia, Times New Roman, Serif; font-weight: bold; color: #AAAAAA" ><em>W</em></sup> è una tecnica di realizzazione e visione di immagini, disegni, fotografie e filmati, finalizzata a trasmettere una illusione di tridimensionalità, analoga a quella generata dalla visione binoculare del sistema visivo umano. La visione stereoscopica consente di inferire la struttura tridimensionale di una scena osservata da due o piu’ telecamere (nel caso di due telecamere si parla di visione binoculare).</p>
<p><span id="more-468"></span></p>
<p>Il principio alla basa della visione stereoscopica, noto sin dal rinascimento, consiste in una triangolazione mirata a mettere in relazione la proiezione di un punto della scena sui due (o più) piani immagine delle telecamere (e.g. tali punti sono denominati punti omologhi) che compongono il sistema di visione stereoscopico (stereo rig). L’individuazione dei punti omologhi, problema noto in letteratura come il problema della corrispondenza (correspondence problem o matching stereo), consente di ottenere una grandezza denominata disparità (disparity) mediante la quale, conoscendo opportuni parametri del sistema stereoscopico, è possibile risalire alla posizione 3D del punto considerato.</p>
<p>&nbsp;</p>
<p style="text-align: justify;">Se volete approfondire l&#8217;argomento in maniera esaustiva vi consiglio di iniziare a leggere l&#8217;<a href="http://www.vision.deis.unibo.it/smatt/VisioneStereo/Stereo+Appendice.pdf" target="new">articolo</a><a> di </a><a href="http://www.vision.deis.unibo.it/smatt/" target="new">Stefano Mattoccia</a>.</p>
<p>&nbsp;</p>
<p style="text-align: justify;">Partendo dal <a title="Camera Player con QT4 e OpenCV" href="http://blog.roccoagostino.eu/2009/12/02/camera-player-con-qt4-e-opencv/">codice</a> dove catturavo il flusso video da una sola webcam per visualizzarlo su una &#8220;label&#8221;, questa volta ho cercato di catturare il flusso video da due webcam e visualizzarle contemporaneamente sullo schermo. Per una maggiore fluidità nel refresh delle immagini (almeno 30 frame al secondo) ho usato le librerie opengl. Unico accorgimento: non collegare le due webcam sullo stesso canale USB (hub USB).</p>
<p>&nbsp;</p>
<p><strong>Ambiente di programmazione:</strong></p>
<ul>
<li>C++ basato sul tool MINGW</li>
<li>framework QT 4.7.4</li>
<li>IDE QTcreator 2.3</li>
<li>librerie OpenCV 2.3.1</li>
</ul>
<p>&nbsp;</p>
<p style="text-align: justify;">Ringrazio Walter Lucetti che mi ha evitato ore ed ore di studio per utilizzare le <a href="http://www.robot-home.it/blog/informatica/tutorial-qt4-e-opencv-widget-opengl-per-visualizzare-immagini/" target="new">opengl in ambiente QT4.</a></p>
<p>&nbsp;</p>
<p><img class="aligncenter size-full wp-image-496" title="webcam" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/09/webcam.jpg" alt="" width="400" height="294" /></p>
<p style="text-align: center;"><strong>Le webcam utilizzate</strong></p>
<p>&nbsp;</p>
<p style="text-align: center;"><iframe title="YouTube video player" class="youtube-player" type="text/html" width="425" height="344" src="http://www.youtube.com/embed/LVpUHQjo-Iw" frameborder="0" allowFullScreen="true"> </iframe></p>
<p>&nbsp;</p>
<p style="text-align: center;"><strong>Il programma in esecuzione</strong></p>
<p>&nbsp;</p>
<p>Ed ecco il codice:<br />
Note: There is a file embedded within this post, please visit this post to download the file.<br />
ovviamente dovete cambiare il percorso delle lib e degli include relative a OpenCV.<br />
Enjoy it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2011/09/22/stereovisione-con-opencv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Camera Player con QT4 e OpenCV</title>
		<link>http://blog.roccoagostino.eu/2009/12/02/camera-player-con-qt4-e-opencv/</link>
		<comments>http://blog.roccoagostino.eu/2009/12/02/camera-player-con-qt4-e-opencv/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 21:27:57 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[QT4]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[programmazione]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=426</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/12/opencv-logo_p.jpg" width="32" height="32" alt="" title="OpenCV" /><img src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/12/Qt4logo_p.jpg" width="32" height="32" alt="" title="QT4" /><br/>Vi presento il mio piccolo ed umile progetto: un player, molto spartano, che visualizza il flusso video catturato da una webcam. &#160; Ambiente di programmazione: C++ basato sul tool MINGW framework QT 4.5.3 IDE QTcreator 1.2.1 librerie OpenCV &#160; Il framework QT permette di creare programmi multipiattaforma: modificando solo il percorso delle librerie e degli [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/12/opencv-logo_p.jpg" width="32" height="32" alt="" title="OpenCV" /><img src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/12/Qt4logo_p.jpg" width="32" height="32" alt="" title="QT4" /><br/><p style="text-align: justify;">Vi presento il mio piccolo ed umile progetto: un player, molto spartano, che visualizza il flusso video catturato da una webcam.</p>
<p>&nbsp;</p>
<p><strong>Ambiente di programmazione:</strong></p>
<ul>
<li>C++ basato sul tool MINGW</li>
<li>framework QT 4.5.3</li>
<li>IDE QTcreator 1.2.1</li>
<li>librerie OpenCV</li>
</ul>
<p><span id="more-426"></span></p>
<p>&nbsp;</p>
<p style="text-align: justify;">Il framework QT permette di creare programmi multipiattaforma: modificando solo il percorso delle librerie e degli &#8220;include&#8221; posso compilare lo stesso pregramma e crearmi degli eseguibili per win32, linux32 o macosx. Le OpenCV sono delle librerie opensource per la computer vision e per maggiori ragguagli vi rimando a questo dettagliato <a href="http://www.matteolucarelli.net/opencv/opencv-dev142.pdf" target="_blank">articolo</a> di Matteo Lucarelli.</p>
<p>&nbsp;</p>
<p><strong>Link:</strong><br />
<a href="http://qt.nokia.com/downloads/sdk-windows-cpp" target="_blank">QT 4.5.3 win32</a><br />
<a href="http://qt.nokia.com/downloads/sdk-linux-x11-32bit-cpp" target="_blank">QT 4.5.3 linux32</a><br />
<a href="http://qt.nokia.com/downloads/sdk-mac-os-cpp" target="_blank">QT 4.5.3 macosx</a></p>
<p><a href="http://sourceforge.net/projects/opencvlibrary/files/" target="_blank">OpenCV library</a><br />
<a href="http://opencv.willowgarage.com/wiki/" target="_blank">di tutto  e di più sulle OpenCV</a></p>
<p>&nbsp;</p>
<p style="text-align: justify;">Il codice è molto semplice, l&#8217;unica difficoltà riscontrata è stata su come far visualizzare l&#8217;immagine della cam sul widget. Scorrazzando su internet ho trovato del codice che mi ha permesso di trasformare l&#8217;immagine rilasciata dalla libreria opencv in una label.<br />
Di seguito il risultato su tre diversi S.O.</p>
<p>&nbsp;</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-429" title="qtcamwin32" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/12/qtcamwin32.jpg" alt="qtcamwin32" width="365" height="349" /></p>
<p>&nbsp;</p>
<p style="text-align: center;">WIN7</p>
<p>&nbsp;</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-431" title="qtcam_linux" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/12/qtcam_linux.jpg" alt="qtcam_linux" width="363" height="349" /></p>
<p>&nbsp;</p>
<p style="text-align: center;">Linux Ubuntu 9.10</p>
<p>&nbsp;</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-430" title="qtcam_macosx" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/12/qtcam_macosx.jpg" alt="qtcam_macosx" width="360" height="370" /></p>
<p>&nbsp;</p>
<p style="text-align: center;">Mac OS X 10.5.8</p>
<p>&nbsp;</p>
<p style="text-align: justify;">Ed ecco il codice:<br />
Note: There is a file embedded within this post, please visit this post to download the file.<br />
ovviamente dovete cambiare il percorso delle lib e degli include relative a OpenCV; visto che questo punto l&#8217;ho studiato per tutti e tre i S.O. se avete problemi chiedete pure.</p>
<p>&nbsp;</p>
<p>Enjoy it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2009/12/02/camera-player-con-qt4-e-opencv/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sviluppare applicazioni per Mac OSX</title>
		<link>http://blog.roccoagostino.eu/2009/10/18/sviluppare-applicazioni-per-mac-osx/</link>
		<comments>http://blog.roccoagostino.eu/2009/10/18/sviluppare-applicazioni-per-mac-osx/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 23:30:55 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[In evidenza]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[Mac OSX]]></category>
		<category><![CDATA[programmazione]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=352</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/10/apple_ico.png" width="32" height="32" alt="" title="Apple" /><img src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/10/xcode_ico.png" width="32" height="32" alt="" title="Xcode" /><br/>Xcode lavora in congiunzione con Interface Builder (IB), un tool grafico per realizzare interfacce grafiche. Xcode include GCC, che è in grado di compilare codice C, C++, Objective C/C++ e Java. Supporta ovviamente i framework Cocoa e Carbon, oltre ad altri.]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/10/apple_ico.png" width="32" height="32" alt="" title="Apple" /><img src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/10/xcode_ico.png" width="32" height="32" alt="" title="Xcode" /><br/><p>Dopo avere giocherellato con l’OSX 10.5.8, il Leopardo dell’Apple, ho cominciato a navigare sul web googlando alla ricerca di informazioni riguardante la programmazione in ambiente OSX, finché non mi ha incuriosito <a href="http://www.programmazione.it/index.php?entity=eitem&amp;idItem=31151" target="_blank">questo articoletto</a> del 2005, ma che ho scoperto essere ancora di grande attualità.</p>
<p><span id="more-352"></span></p>
<p>Registrato al sito dell’Apple riservato agli sviluppatori (Mac Dev Center), ho scaricato ed installato l’ambiente di sviluppo integrato <a href="http://it.wikipedia.org/wiki/Xcode" rel="nofollow" target="_blank" title="Da Wikipedia la definizione di: Xcode" style="padding-bottom: 2px; border-bottom: 1px dotted #DD0000" >Xcode</a><sup style="font-family: Georgia, Times New Roman, Serif; font-weight: bold; color: #AAAAAA" ><em>W</em></sup> 3.1.2.<br />
Xcode lavora in congiunzione con <a href="http://it.wikipedia.org/wiki/Interface_Builder" rel="nofollow" target="_blank" title="Da Wikipedia la definizione di: Interface Builder" style="padding-bottom: 2px; border-bottom: 1px dotted #DD0000" >Interface Builder</a><sup style="font-family: Georgia, Times New Roman, Serif; font-weight: bold; color: #AAAAAA" ><em>W</em></sup> (IB), un tool grafico per realizzare interfacce grafiche. Xcode include GCC, che è in grado di compilare codice C, C++, Objective C/C++ e Java. Supporta ovviamente i framework Cocoa e Carbon, oltre ad altri.<br />
Mi sono dunque soffermato sull’<a href="http://it.wikipedia.org/wiki/Objective_C" rel="nofollow" target="_blank" title="Da Wikipedia la definizione di: Objective C" style="padding-bottom: 2px; border-bottom: 1px dotted #DD0000" >Objective C</a><sup style="font-family: Georgia, Times New Roman, Serif; font-weight: bold; color: #AAAAAA" ><em>W</em></sup> , linguaggio di <a href="http://it.wikipedia.org/wiki/programmazione_orientata_agli_oggetti" rel="nofollow" target="_blank" title="Da Wikipedia la definizione di: programmazione orientata agli oggetti" style="padding-bottom: 2px; border-bottom: 1px dotted #DD0000" >programmazione orientata agli oggetti</a><sup style="font-family: Georgia, Times New Roman, Serif; font-weight: bold; color: #AAAAAA" ><em>W</em></sup> e su Cocoa , il framework o ambiente di programmazione orientato agli oggetti sviluppato da Apple Inc. per il sistema operativo Mac OS X.<br />
A questo punto, per iniziare, consiglio una lettura attenta, dei primi dieci capitoli (sono abbastanza brevi) del sito <a href="http://www.programmazione.it/index.php?entity=eitem&amp;idItem=31151" target="_blank">MACOCOA</a> e di qualche tutorial (in rete se ne trovano diversi anche in italiano) come:<br />
<a href="http://homepage.mac.com/marco_coisson/Tutorial/" target="_blank">Programmare MacOSX</a><br />
<a href="http://9d1a4226.ultrafiles.net" target="_blank">Diventare un Xcoder (e-book)</a><br />
Presto, dopo essermi ben documentato, le prime impressioni e magari qualche prima piccola applicazione.<br />
Enjoy it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2009/10/18/sviluppare-applicazioni-per-mac-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Creare grafici con la libreria PHPGraphLib</title>
		<link>http://blog.roccoagostino.eu/2009/09/13/php-creare-grafici-con-la-libreria-phpgraphlib/</link>
		<comments>http://blog.roccoagostino.eu/2009/09/13/php-creare-grafici-con-la-libreria-phpgraphlib/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 16:37:25 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[In evidenza]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[programmazione]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=330</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/php_ico.jpg" width="32" height="32" alt="" title="PHP" /><br/>PHPGraphLib è una libreria "preconfezionata", orientata agli oggetti e scritta in php che utilizza le librerie GD. Essa è destinata alla creazione di grafici per l'inserimento di questi ultimi in pagine web. I grafici permettono di mostrare a tutti i dati o risultati numerici in maniera più chiara tramite l'utilizzo di immagini e colori.]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/php_ico.jpg" width="32" height="32" alt="" title="PHP" /><br/><p><strong>PHPGraphLib</strong> è una libreria &#8220;preconfezionata&#8221;, orientata agli oggetti e scritta in php che utilizza le librerie GD. Essa è destinata alla creazione di grafici per l&#8217;inserimento di questi ultimi in pagine web. I grafici permettono di mostrare a tutti i dati o risultati numerici in maniera più chiara tramite l&#8217;utilizzo di immagini e colori. </p>
<p><span id="more-330"></span></p>
<p>L&#8217;uso della libreria facilita il compito agli sviluppatori meno esperti anche perché include un sistema di gestione degli errori molto efficace. I risultati ottenibili con questa libreria sono veramente stupefacenti, la potenza del codice inserito nell&#8217;unica pagina di PHPGraphLib possono essere utilizzati al massimo, date le piccole dimensioni di quest&#8217;ultima.<br />
Sul <a href="http://www.ebrueggeman.com/" target="_blank">sito</a> dell&#8217;autore (Elliott Brueggeman) possiamo trovare la pagina di download da dove scaricare la libreria, disporre della guida ufficiale e di alcuni esempi testuali e video.<br />
Per potere utilizzare PHPGraphLib bisogna salvare i due file contenuti nella libreria, “phpgraphlib.php” e “phpgraphlib_pie.php”, in una cartella. Successivamente occorrerà modificare il file php.ini ed eliminare il commento ( ; ) alla riga “extension=php_gd2.dll” nel caso sia commentata.<br />
Per ultimo occorrerà includere il file *.php della libreria nella nostra pagina php e scrivere il codice per creare il grafico.<br />
<em>Nota: bisogna creare in grafico in una pagina php a parte e richiamarla come imagine nella pagine dove vogliamo visualizzare il grafico.</em></p>
<p>&nbsp;</p>
<p>Vediamo dei semplici esempi:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;phpgraphlib.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$graph</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> PHPGraphLib<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">350</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$data</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">12124</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">5535</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">43373</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">22223</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">90432</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">23332</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">15544</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">24523</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">32778</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">38878</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">28787</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">33243</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">34832</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">32302</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$graph</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addData</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$graph</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setTitle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Widgets Produced&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$graph</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setGradient</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;red&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;maroon&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$graph</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createGraph</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>&nbsp;</p>
<p>salviamolo come &#8220;immagine.php&#8221; e richiamiamo il grafico nella pagina htlm con</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;immagine.php&quot;</span><span style="color: #66cc66;">/</span>&gt;</span></pre></div></div>

<p>&nbsp;</p>
<p>il risultato è il seguente:</p>
<p>&nbsp;</p>
<p><a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/09/grafico.JPG"><img src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/09/grafico.JPG" alt="grafico" title="grafico" width="492" height="333" class="aligncenter size-full wp-image-331" /></a></p>
<p>&nbsp;</p>
<p>Nella pagina <a href="http://blog.roccoagostino.eu/statistiche/" target="_blank">Statistiche</a> di questo blog ho utilizzato queste librerie.<br />
Nel caso del diagramma a torte, per esempio, passo dinamicamente i valori da diagrammare in questo modo:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?php echo &quot;</span>statistiche_torta.php?a<span style="color: #66cc66;">=</span>$a&amp;r<span style="color: #66cc66;">=</span>$r&amp;s<span style="color: #66cc66;">=</span>$s&amp;m<span style="color: #66cc66;">=</span>$m<span style="color: #ff0000;">&quot; ?/&gt;</span></span>&quot; /&gt;</pre></div></div>

<p>&nbsp;</p>
<p>Nel file &#8221; statistiche_torta.php&#8221;</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #b1b100;">include</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;phpgraphlib.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">include</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;phpgraphlib_pie.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$a</span><span style="color: #339933;">=</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$r</span><span style="color: #339933;">=</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'r'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$s</span><span style="color: #339933;">=</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'s'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$m</span><span style="color: #339933;">=</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'m'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$graph</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> PHPGraphLibPie<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">450</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">250</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$data</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Aggregatori&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Motori di ricerca&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$r</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Social Network&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$s</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;E.mail&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$m</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$graph</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addData</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #000088;">$graph</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLabelTextColor</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;silver&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$graph</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLegendColor</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;silver&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$graph</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLegendOutlineColor</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;white&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    
    <span style="color: #000088;">$graph</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setTitle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Parlano di me....&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$graph</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLabelTextColor</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;50,50,50&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$graph</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLegendTextColor</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;50,50,50&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$graph</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createGraph</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>&nbsp;</p>
<p>Ovviamente è possibile passare direttamente l&#8217;array da diagrammare oppure ricavare i valori eseguendo query in mysql, complicando il codice.</p>
<p>&nbsp;</p>
<p><strong>Enjoy it!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2009/09/13/php-creare-grafici-con-la-libreria-phpgraphlib/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uso di jQuery per creare una semplice interfaccia tab con immagini per etichette</title>
		<link>http://blog.roccoagostino.eu/2009/09/06/uso-di-jquery-per-creare-una-semplice-interfaccia-tab-con-immagini-per-etichette/</link>
		<comments>http://blog.roccoagostino.eu/2009/09/06/uso-di-jquery-per-creare-una-semplice-interfaccia-tab-con-immagini-per-etichette/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 22:29:02 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[JavaScript & AJAX]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[programmazione]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=225</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/ajax_ico.png" width="32" height="32" alt="" title="JavaScript &amp; AJAX" /><br/>Un effetto molto gradevole ed utile nell’economia di un sito web è senz’altro un’interfaccia a tab. JQuery permette di crearne di complesse ma la volontà di questo articolo è descriverne uno base, semplice, ma comunque funzionale e facilmente adattabile a molte esigenze. Il risultato è questo: demo Nel pacchetto oltre allo script jQuery, troverete anche [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/ajax_ico.png" width="32" height="32" alt="" title="JavaScript &amp; AJAX" /><br/><p>Un effetto molto gradevole ed utile nell’economia di un sito web è senz’altro un’interfaccia a tab. JQuery permette di crearne di complesse ma la volontà di questo articolo è descriverne uno base, semplice, ma comunque funzionale e facilmente adattabile a molte esigenze.</p>
<p><span id="more-225"></span></p>
<p>
Il risultato è questo: <a href="http://www.roccoagostino.eu/demo/navtab/index.html" target="_blank">demo</a><br />
<br />
Nel pacchetto Note: There is a file embedded within this post, please visit this post to download the file.<br />
oltre allo script <a href="http://www.jquery.com/" target="_blank">jQuery</a>, troverete anche i file e la cartella:</p>
<ul>
<li>index.htm</li>
<li>style.css</li>
<li>scripts.js</li>
<li>cartella images</li>
</ul>
<h2><strong>Passo 1 – creazione delle immagini</strong></h2>
<p>Decidete quanti tab sono necessari al vostro progetto (nel mio caso 3). Se non siete bravi in grafica e design cercate su internet le immagini che concettualmente si avvicinano al contenuto di ogni tab.<br />
Modificate le dimensioni tenendo conto dello spazio che volete utilizzare.<br />
A questo  punto duplicate la vostra immagine e  modificatela con effetti a piacere. Una volta terminato, create una nuova immagine ed incollate sopra la figura modificata e sotto la figura originale. (vedi immagine)<br />
<a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/09/doppia-immagine.PNG"><img class="aligncenter size-full wp-image-226" title="doppia immagine" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/09/doppia-immagine.PNG" alt="doppia immagine" width="559" height="221" /></a><br />
</p>
<h2><strong>Passo 2 – file HTML e CSS</strong></h2>
<p>Se aprite il file index.html troverete:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tabMenu&quot;</span>&gt;</span>  
     <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tabrss selected&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span> <span style="color: #808080; font-style: italic;">&lt;!-- bottone di default--&gt;</span>  
     <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tabpost&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>  
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tabcom&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>  
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></div></div>

<p>Nel file style.css, il div &#8220;tabMenu&#8221; è associato a:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">li<span style="color: #6666ff;">.tabcom</span>  <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">images/tabcom.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-77px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
li<span style="color: #6666ff;">.tabrss</span>  <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">images/tabrss.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-77px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
li<span style="color: #6666ff;">.tabpost</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">images/tabpost.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-77px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>  
li<span style="color: #6666ff;">.mouseover</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
li<span style="color: #6666ff;">.mouseout</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">-77px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
li<span style="color: #6666ff;">.selected</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Come potete notare di default l&#8217;immagine (di dimensioni 77px / 77px) parte da -77 px (quindi viene vusualizzata la sezione a colori), se si passa il cursore del mouse sopra (voce &#8220;li.mouseover&#8221; nel file style.css) parte da 0 px (quindi viene visualizzata la sezione in b/n), così come quando viene selezionata (voce &#8220;li.mouseover&#8221; nel file style.css). Quindi avremo, a secondo i casi, una situazione del genere:<br />
<a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/09/colore_bn.PNG"><img class="aligncenter size-full wp-image-227" title="colore_bn" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/09/colore_bn.PNG" alt="colore_bn" width="328" height="286" /></a><br />
Il contenuto delle tre  tab (ma se ne possono aggiungere altre a piacere) andrà inserito nella seguente struttura contenuta nel file index.html:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;boxBody&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;posts&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;show&quot;</span>&gt;</span>    <span style="color: #808080; font-style: italic;">&lt;!-- pagina di default--&gt;</span>  
&nbsp;
......................<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;famous&quot;</span>&gt;</span>
&nbsp;
...............<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;comments&quot;</span>&gt;</span>
&nbsp;
.................<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>Ovviamente bisogna lavorare di CSS per rendere il tutto più gradevole.<br />
</p>
<h2><strong>Passo 3 – file JS</strong></h2>
<p>Nel file script.js è contenuta la funzione per la gestione dei tab con l&#8217;effetto a finestra nel cambio tra un tab e l&#8217;altro.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//nasconde il tab precedente</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.boxBody div'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//visualizza il tab selezionato</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.boxBody div:eq('</span> <span style="color: #339933;">+</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#tabMenu &amp;gt; li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">index</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">')'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'1500'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In questo modo utilizziamo solo la libreria jQuery. Se voglamo altri effetti, come il fade alle immagini (invece della tecnica sopra illustrata) o altri effetti sul contenuto dei tab, ovviamente il file script.js sarà più complicato ed inoltre sarà necessario caricare i plugin di jQuery.</p>
<p>Enjoy it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2009/09/06/uso-di-jquery-per-creare-una-semplice-interfaccia-tab-con-immagini-per-etichette/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  blog.roccoagostino.eu/tag/how-to/feed/ ) in 2.06659 seconds, on Feb 6th, 2012 at 11:53 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 13th, 2012 at 11:53 am UTC -->
