Home › Forum › Problemi Vari con WP › sidebar diversa in tutte le pagine
-
AutorePost
-
-
18 Ottobre 2008 alle 14:42 #8233dad388Partecipante
ciao!
non so se ne avete già parlato (i non ho trovato) volevo sapere qual’è il codice php per avere una sidebar diversa per ogni pagina.
so come fare quello per averla diversa dalla homepage fatto con un if ma non saprei come fare in modo semplice quello per avere una sidebar differente….
grazie ciao
-
19 Ottobre 2008 alle 9:23 #58637wollyAmministratore del forum
non è possibile usare una sidebar diversa per ogni pagina.
puoi utilizzando i tag is usare una sidebar diversa per la home, per la single, per le pagine, per gli archivi etc.
-
20 Ottobre 2008 alle 7:50 #58655dad388Partecipante
scusa se insisto ma allora x’ nel munu dove inserire i plugin nella sidebar c’è il menu a tendina che teoricamente ti permette di gestire più di una sidebar?
grazie
-
20 Ottobre 2008 alle 7:55 #58656wollyAmministratore del forum
scusa ma non ho capito quello che vuoi dire puoi per favore rispiegare quello che intendi?
ciao
-
20 Ottobre 2008 alle 18:01 #58667dad388Partecipante
allora io ho bisogno di avere una sidebar diversa per ogni pagina del mio sito
ho trovato il modo per averla diversa dalla home con un if…
ora mi chiedevo se esiste un codice che mi permetta di avere una sidebar fatta su misura per ogni pagina con i vari plugin.
ora io credo che con uno switch si potrebbe fare ma non potrei mettere i plugin nelle altre sidebar ma solo in quella della home perchè wordpress mi visualizza una sola sidebar.
spero di esser stato un pò più chiaro
grazie ancora
-
20 Ottobre 2008 alle 22:28 #58672gollum1Partecipante
la maniera più semplice per avere delle sidebar diverse a seconda della pagina che stai caricando è lasciar perdere le sidebar con widget e lavorare direttamente con il codice nella diverse sidebar, in pratica ti costruisci un file sidebar_1.php … sidebar_n.php e poi nel file sidebar.php che usi normalmente con una serie di if carichi la sidebar effettiva che ti interessa.
la stessa cosa potresti fare anche con le sidebar con widget, ma la cosa diventa un pochino più complessa, per prima cosa devi andare a modificare il file function.php per indicare quande sidebar con gestione di widget intendi usare, e poi andare a gestire il file sidebar, in cui vai a ripetere il codice che carica il widget per ogni sidebar, tenendo presente che devi poi inserire il tutto in un un flusso di if…then che ti differenzi le singole pagine…
come ti diceva le if le fai con is_page() come ti diceva wolly.
data l’ora forse non sono stato il massimo della chiarezza, se hai altri dubbi scrivi…
Byez
—
Gollum1
-
21 Ottobre 2008 alle 10:30 #58678dad388Partecipante
ok..speravo si potesse evitare la serie di if..
cmq ora provo con gli if o uno switch…mentre siccome mi piacerebbe sarepere come fare la storia dei plugin che mi stavi dicendo dove trovo una guida o il codice che devo inserire nel file function.php
oppure se mi spieghi come fare cercherò di ricavarmi io il codice…
grazie
ciao
-
21 Ottobre 2008 alle 21:31 #58683gollum1Partecipante
prendi due temi, uno con una sidebar widget ready e una con due sidebar widget ready, confronti le due funtion.php e ti rendi conto subito di qual’é la differenza…
1) register_sidebar per la sidebar singola
2) register_sidebars per le sidebar multiple (nota la s finale).
poi cerchi su codex.wordpress.org le due funzioni e hai tutti i dati per lavorare…
a quel punto puoi fare anche una sola sidebar, con una sola funzione per inserire la sidebar (in fondo vuoi mettere una sidebar solo per ogni pagina, giusto?) e semplicemente usi una variabile che cambi in funzione della pagina per indicare quale sidebar usare.
praticamente nella seguente riga usi $sidebarnumber per indicare quale sidebar caricare, e quindi con lo switch non fai altro che cambiare questa variabile mettendovi il numero che ci vuole…
if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar($sidebarnumber) ) :
spero di essermi spiegato…
in caso di necessità sono sempre qui…
Byez
—
Gollum1
-
26 Ottobre 2008 alle 14:14 #58804dad388Partecipante
ciao!
oggi sono riuscito a provare quello che mi hai consigliato ma ho un problema ora!
sono riuscito a fare la prima pagina dicendo allo switch con is_home() che se è la home di mettermi la sidebar che voglio ma ora non saprei come richiamare le altre pagine.
grazie
-
26 Ottobre 2008 alle 14:52 #58807ondapiPartecipante
http://wordpress.org/extend/plugins/page-sidebars/
questo potrebbe fare al caso tuo specie se hai da aggiungere del testo
è ottimo per i temi a due colonne ma funziona bene con tutto il resto
-
26 Ottobre 2008 alle 15:08 #58808dad388Partecipante
grazie mille!
ora lo provo…
cmq scusa se stresso ma mi piacerebbe cmq sapere cm fare con il codice..
cioè cm vado a indicare la pagina che mi serve, ora stavo provando cosà¬:
<?php
switch ($i) {
case (is_home()):
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar($sidebar1) )
include ( TEMPLATEPATH . '/sidebar1.php' );
break;
case (is_squadra()):
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar($sidebar_team) )
include ( TEMPLATEPATH . '/sidebar_team.php' );
break;
case altra pagina:
sidebar della pagina
break;
}
?>
grazie
-
26 Ottobre 2008 alle 17:20 #58814gollum1Partecipante
cosଠperò carichi le sidebar in modo statico, senza fare uso dei widget, o meglio, nei diversi file che vai a costruire devi dare un’indicazione diversa della sidebar…
se facevi come ti ho indicato prima, con un unico file avresti avuto la sidebar che ti serviva per ogni pagina…
in quel modo lo switch ti serviva solamente per cambiare la variabile che fornisce il numero della sidebar da caricare.
naturalmente in ogni sidebar o in un punto sempre fisso devi mettere dei link alle varie pagine, perché se perdi il link alle pagine, non hai più possibilità di scorrerle…
Byez
—
Gollum1
-
26 Ottobre 2008 alle 17:59 #58818dad388Partecipante
allora mi sa che nn ho capito cosa intendevi tu….
ora ho anke un altro problema con il sito….cercando di portare come prima pagina non il posto ma una pagina ho cambiato l’indirizzo e da quando ho dato l’invio mi fa vedere il sito cosଠhttp://david888.altervista.org/wordpress/index.php
sapete aiutarmi?
-
26 Ottobre 2008 alle 21:38 #58826gollum1Partecipante
hai cannato qualcosa nel riferimento del tema, praticamente non ti viene caricato il css…
rimetti i riferimenti al sito come erano…
vedrai che tutto va bene…
Byez
—
Gollum1
-
26 Ottobre 2008 alle 21:44 #58828gollum1Partecipante
@import url( http://david888.altervista.org/wordpress/?page_id=67/wp-content/themes/aeros/style.css
da qualche parte nella gestione del tuo sito dove ti chiede dove è installato wp devi mettere:
david888.altervista.org/wordpress/
mentre dove ti chiede qual’é la pagina principale del tuo sito devi mettere:
david888.altervista.org
Non puoi avere un singolo post come pagina principale, ma puoi avere una singola pagina, se la costruisci per farti vedere quel singolo post hai risolto il tuo problema….
Byez
—
Gollum1
-
26 Ottobre 2008 alle 23:22 #58837dad388Partecipante
si il punto però è che nn posso accedere a nessuna impostazione quindi dovrei entrare e inserire a mano….ma nn saprei dove…mentre il metodo che mi dicevi tu per la sidebar com’era che evidentemente non ho capito che intendevi…
grazie mille per le risposte!!
-
27 Ottobre 2008 alle 13:26 #58847gollum1Partecipante
Non è vero, se sai di preciso dove l’hai messo, inserisci tutto il path:
david888.altervista.org/wordpress/wp-admin/
ed accedi direttamente all’amministrazione del sito…
comincia a rimettere in piedi il sito, poi vediamo come sistemare la sidebar
byez
—
Gollum1
-
27 Ottobre 2008 alle 14:53 #58851dad388Partecipante
allora hai presente il link setting? ho wordpress inglese
li ho provato a inserire un path differente per la prima pagina…per fare una prova
e da quando ho dato l’invio mi ha sballato il css
ora però anche se faccio log in e metto i dati giusti non mi fa entrare in wordpress quindi non posso sostituire quel che ho fatto…
ho provato a cercare nei singoli file php ma per ora ho trovato il file con le miei impostazioni per l’installazione di wordpress….tipo nome iniziale del database ecc….ma non il path che ho sostituito…
cmq si hai ragione una cosa alla volta….
-
27 Ottobre 2008 alle 15:15 #58852wollyAmministratore del forum
nel blog di wordpress-it cerca il post mamma ho perso il sito e segui le istruzioni, tornerà tutto a posto
-
27 Ottobre 2008 alle 17:57 #58865gollum1Partecipante
Non importa se non ti fa entrare immediatamente… una volta che hai fatto il login ha caricato l’autorizzazione nel cookies, quindi tutte le pagine che girearai poi di seguito non ti chiederanno più l’autorizzazione.
quindi una volta che hai fatto il login vai nella pagina di amministrazione mettendo il path completo alla pagina di amministrazione (quello che ti ho indicato prima).
altra soluzione, entrare con myphpadmin direttamente nel DB e andare a correggere il campo del DB in cui c’é l’indicazione sbagliata del sito.
entrambe le soluzioni sono valide, la prima può essere fatta anche da chi non conosce nulla di DB e non vuole metterci direttamente le mani.
Byez
—
Gollum1
-
28 Ottobre 2008 alle 0:41 #58872dad388Partecipante
ok stile css del sito ripristinato,
grazie a tutti e due…
-
28 Ottobre 2008 alle 17:41 #58910dad388Partecipante
scusate se in questo modo vado contro il regolamento del forum ma volevo chiede a gollum1 se poteva spiegarmi meglio quello che intendeva per farmi avere le sidebar dinamiche..
grazie mille e scusa se sto facendo questo up indiretto
-
28 Ottobre 2008 alle 20:03 #58918gollum1Partecipante
Personalmente non ho problema, sarebbe più semplice se tu venissi sul canale IRC dedicato a wordpress-it (server azzurra).
comunque il sistema per avere più sidebar si divide in due parti, in due file separati:
1) nel file function.php in cui si indicano quante saranno le sidebar in totale.
2) nel file sidebar.php ci metti il codice per visualizzare le sidebar…
il mio pensiero per quanto riguarda il tuo modo di voler visualizzare le sidebar, una sidebar diversa per ogni pagina, è che è inutile ripetere il codice della visualizzazione della sidebar per ogni sidebar, ma il codice è unico…
praticamente all’inizio del file con lo switch determini il numero della sidebar che vuoi visualizzare
poi non fai altro che mettere un unico codice per la sidebar, in cui indichi il numero che hai memorizzato prima.
è veramente più facile farlo che stare qui a dirlo…
Byez
—
Gollum1
-
28 Ottobre 2008 alle 21:30 #58926dad388Partecipante
si sicuramente sarà più facile farlo….è sempre cosଠalla fine…
cmq ora cerco il canale irc e ti contatto li…
grazie per la pazienza
-
16 Gennaio 2009 alle 0:42 #61302dad388Partecipante
ciao a tutti!
scusate il forte ritardo ma ora dopo questo mio gravissimo errore vi faccio vedere come ho risolto al mio problema delle multi-sidebar grazie all’aiuto di gollum1.
prima di tutto decidiamo quante sidebar ci servono e andiamo nel file functions.php e modifichiamolo in modo che wordpress capisca quante sidebar deve aspettarsi, ecco il codice:
<?php
if ( function_exists('register_sidebars') ) /*<
state molto attenti a inserire la s del pluraleregister_sidebars(7, array( /*<----anche qui inserite la s del plurale e dove vedete il 7 inserite il vostro n° sidebar
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
));
?>
ora che la prima parte è completata passiamo al file sidebar.php e inserite il controllo if prima di ogni altra cosa, inserendolo tra i tag <?php if bla bla ?>
potete vedere che ho avuto la necessita di avere 7 sidebar e non c'è stato alcun problema.
bè l'if non è fatto al meglio ma va.
/*inizio if per gestire le varie sidebar per le relative pagine
<?php
if (is_page(42)){ <---- se è la pagina numero 42 allora usa la sidebar4 e cosଠcon il resto delle pagine e sidebar
$sidebarnum=4;
}else{
if (is_page(51)||is_page(53)||is_page(55)||is_page(57)||is_page(61)||is_page(75)||is_page(420)||is_page(820)){
$sidebarnum=2;
}else{
if (is_page(47)){
$sidebarnum=5;
}else{
if (is_page(49)){
$sidebarnum=6;
}else{
if (is_page(164)||is_page(173)||is_page(182)||is_page(184)||is_page(207)||is_page(220)||is_page(224)||is_page(268)){
$sidebarnum=3;
}else{
if (is_home()||is_page(40)){
$sidebarnum=1;
}else{
$sidebarnum=7; <
se nessuna delle altre condizioni mi va bene fai apparire la sidebar7}
}
}
}
}
}
?>
/* fine gestione multi-sidebar
una volta finito di modificare questi file si può andare tranquillamente nella sezione widget e modificare ogni singola sidebar.
spero di poter esser di aiuto a qualcuno.
ciao a tutti e buon wordpress
-
27 Ottobre 2009 alle 12:22 #69071MurackPartecipante
Salve a tutti
mi inserisco per chiedere un chiarimento
io vorrei creare una sidebar specifica per una pagina ( ma non escludo di farne una specifica per altre pagine in futuro)
la spiegazione di dad388 mi è abbastanza chiara, tranne un punto:
nn mi è chiaro se devo creare una sidebar2.php (ricopiando il contenuto della sidebar.php orginale) e come poi la richiamo in functions.php e nella sidebar.php
se andate nel mio sito, il mio obiettivo è eliminare quel contenuto in flash in alto (non sono un esperto in questo campo e quindi ho utilizzato wix) nella pagina serate, lasciando nelle altre pagine
quel contenuto l’ho inserito manualmente nella sidebar.php
che mi sapete dire? avete una diversa soluzione più semplice?
grazie in anticipo
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.