Home › Forum › Plugin e temi di WP › Sidebar che cambia a seconda della pagina
-
AutorePost
-
-
10 Maggio 2007 alle 10:09 #3739novellinoPartecipante
Salve, vorrei che la sidebar del mio blog avesse degli elementi grafici diversi a seconda della pagina. Per elementi grafici intendo banner pubblicitari. Come posso fare?
-
10 Maggio 2007 alle 10:41 #44626ondapiPartecipante
puoi creare dei template di pagina differenti
-
10 Maggio 2007 alle 11:05 #44627novellinoPartecipante
nel tema default, ho notato questa riga di codice:
<?php /* Se questa è la pagina principale */ if ( is_home() || is_page() ) { ?>
Pensavo di utilizzare una cosa del genere, ma non so come si fa. Chi mi può aiutare?
-
10 Maggio 2007 alle 17:22 #44644ondapiPartecipante
prova a leggere questo post penso ti possa aiutare
-
10 Maggio 2007 alle 22:18 #44648novellinoPartecipante
Ho dato una occhiata ed effettivamente mi sembra la strada giusta. Ho provato a fare le modifiche ma la sintassi, che non conosco, credo che sia sbagliata. Puoi aiutarmi? Di seguito il codice che ho provato ad inserire nella sidebar:
<?php
if (is_home()) {
<div align="center"><script language="javascript">Contenuto dello script 1</script></div>
} elseif (is_page(2)) {
<div align="center"><script language="javascript">Contenuto dello script 2</script></div>
} else {
<div align="center"><script language="javascript">Contenuto dello script 3</script></div>
}
?>
-
11 Maggio 2007 alle 13:10 #44655novellinoPartecipante
Ho provato anche cosଠma non funzona ugualmente:
<?php
if (is_home()) {
echo "<div align="center"><script language="javascript">Contenuto dello script 1</script></div>";
} elseif (is_page(2)) {
echo "<div align="center"><script language="javascript">Contenuto dello script 2</script></div>";
} else {
echo "<div align="center"><script language="javascript">Contenuto dello script 3</script></div>";
}
?>
Non c’è nessuno che sa come fare? Vi prego è importante!
-
11 Maggio 2007 alle 19:42 #44658ondapiPartecipante
prova con questo
<?php if (is_page(2)) { ?>inserisci testo<?php } ?>
<?php if (is_page(3)) { ?>inserisci altro testo<?php } ?>
probabilmente è migliorabile come codice ma mi funziona
puoi inserirlo dirattamente in page.php
al posto di
<?php get_sidebar(); ?>
metti<?php if (is_page(2)) { ?><?php get_sidebar(); ?> <?php } ?>
<?php if (is_page(3)) { ?><div id="sidebar">hello</div> <?php } ?>
<?php if (is_page(4)) { ?><div id="sidebar"><?php include (TEMPLATEPATH . '/searchform.php'); ?></div> <?php } ?>
-
11 Maggio 2007 alle 23:03 #44659novellinoPartecipante
Sei un grande, il codice funziona benissimo!
-
27 Febbraio 2008 alle 16:45 #51120ciopin183Partecipante
Ragazzi,
ho letto i vostri post con molta invidia. Io sono da giorni e giorni che sto provando ad allineare la mia sidebar a destra. Usando il teme mystify-40 ho visto che aprendo il sito con firefox tutto va bene ma con explorer mi ritrovo le mie widgets in fondo alla pagina. Ho provato ad inserire le DIV <div style=”text-align:right”> <div style=”margin:auto”> </div></div> ma se anche riesco ad allinearla a destra mi si sfasa la grafica, il colore di sfondo della sidebar. Credo che la strada dei div sia quella giusta ma dove vanno inseriti: nel style.css nel sidebar.php?
Mi aiutate a capire?
Grazie
Umberto
-
27 Febbraio 2008 alle 19:57 #51128ondapiPartecipante
invece di usare <div style=”text-align:right”>
non ti converrebbe dare una classe al tuo div e poi richiamarla nel css e dere i tag appropriati
che la visualizzazione su ie (6 in particolate) sia diversa dagli altri browser è cosa saputa, e questo la dice lunga sui formati standard…
di solito che da proglemi sono i tag margin dei div nel css, potresti dare dei valori diversi tra ie e gli altri browser tipo
.latuaclassdeldiv {
padding: 10px 15px 20px 20px;
margin: 10px 10px 10px 20px;
*margin: 10px 10px 10px 10px; /* IE6 hack */
}
la seconda stinga del margin dovrebbe essere letta da ie
io sono riuscito a correggere cosଠalcune sidebar che avevo forse malamente modificate, oppure caricare a seconda del browser una css personalizzato,
c’è qualcosa nel forum
-
27 Febbraio 2008 alle 23:08 #51134gollum1Partecipante
un consiglio spassionato:
-
28 Febbraio 2008 alle 9:32 #51144emekPartecipante
scusa ma non fai prima a ricrearti completamente un nuovo css solo per ie6 e lo richiami in tutte le pagine con una istruzione condizionale?
Cosଠhai piena libertà di movimento sui vari browser, il lavoro è un po + lungo però facendo cosଠstai sicuro che non spacchi il layout giusto su firefox
-
28 Febbraio 2008 alle 19:14 #51193ciopin183Partecipante
Ciao Ondapi,
prima di tutto ti ringrazio per avermi risposto. Ti chiedo scusa ma ma non ho ben capito se il codice che mi hai suggerito
.latuaclassdeldiv {
padding: 10px 15px 20px 20px;
margin: 10px 10px 10px 20px;
*margin: 10px 10px 10px 10px; /* IE6 hack */
}
devo inserirlo nel file style.css, nel file sidebar.php o in tutte e due. purtroppo pur avendo seguito il consiglio di gollum e avendo dato un’occhiata alle varie guide in rete non capisco dove mettere i codici.
Poi perchè tutta questa differenza tra firefox e explorer? Ho persino diffcoltà a caricare un’immagine sulla sidebar inserendo l’url in un widgets di testo…con firefox lo visualizzo con explorer no.
PS
Emek, purtroppo non sono capace di ricostruirmi un codice css ad hoc come mi hai suggerito.
-
28 Febbraio 2008 alle 22:26 #51194ciopin183Partecipante
Ci sono riuscito!!!Ci sono riuscito!!!
Ho inserito nella #sidebar
position:absolute;
left: 570px;
Il valore 570px l’ho trovato facendo delle prove.
Però cosଠfacendo non mi compare più il bordo colorato che mi contornava la sidebar. Per inciso è questa: http://www.ciopin.altervista.org/sideheadtop.gif
Come faccio..stavolta ad allinearla. Ho provato ad inserire il codice position:absolute e left:570px ma non cambia nulla.
-
29 Febbraio 2008 alle 11:14 #51200GuardRailPartecipante
prova con questo
t
probabilmente è migliorabile come codice ma mi funziona
puoi inserirlo dirattamente in page.php
al posto di
t
metti
t
Mi serviva questo codice proprio per visualizzare elementi diversi a seconda delle pagine o sottopagine visualizzate.
Volevo sapere però come si fa ad indicare più pagine e le relative sottopagine?
Ho fatto cosଠif (is_page(6||10)) dove 10 è sottopagina di 6, ma per evitare di elencarle tutte (e di doverle aggiungere a mano se se ne creano delle altre)?
In pratica vorrei che per la pagina x e le relative sottopagne di x ci fosse lo stesso contenuto.
Ho provato con child_of ma sembra che non vada.
Grazie
-
29 Febbraio 2008 alle 12:10 #51201SteveAglAmministratore del forum
devi elencarle tutte…
-
29 Febbraio 2008 alle 12:25 #51202GuardRailPartecipante
é la tua risposta definitiva? L’accendiamo? :p
In realtà mi sono accordo che (6||10) noion funge.. quindi devo ripetere tutto il contenuto per ogni singola pagina.. il file sidebar.php diventerà luuuuunghissimo :'(
va bene..cmq visto che non si può fare altrimenti procedo ad elencarle
PS: avevi detto che la prossima era a pagamento?.. eheheh ciao steve
-
29 Febbraio 2008 alle 14:08 #51210SteveAglAmministratore del forum
no evi far cosà¬:
if (is_page(6)||is_page(10)||is_page(25)… etc)
-
29 Febbraio 2008 alle 15:33 #51227GuardRailPartecipante
Ah ecco…grazie Steve, sempre prezioso
PS: mi consigli un testo online dove apprendere queste basi di php?Finora vado intuito
-
29 Febbraio 2008 alle 16:18 #51232SteveAglAmministratore del forum
hmmm php.net hai il manuale (anche italiano scaricabile anche in formato help window) e dovresti trovare riferimenti ad altre risorse.
-
2 Febbraio 2011 alle 18:36 #80930pittinicchioPartecipante
Si può risolvere cosà¬:
<?php if(is_page('23') || $post->post_parent=="23") {?>
Pippo
<?php } ?>
dove 23 è l'id della pagina alla quale facciamo riferimento..
possiamo decidere che la parola "pippo" piuttosto che qualsiasi altra cosa.. una sidebar,
appaia nella pagina id 23 e nelle sue figlie.
Oppure solo nelle figlie:
<?php if($post->post_parent=="23") {?>
Pippo
<?php } ?>
Lieto di poter essere utile a chi a distanza di 2 anni ancora si imbatte in questo quesito.
(Tipo me)`
-
3 Febbraio 2011 alle 8:45 #80938LangyPartecipante
In alternativa puoi utilizzare il plugin widget logic, è comodissimo, ti aggiunge un campo ad ogni widget e puoi quindi specificargli per quale pagina deve essere visualizzato il widget.
es:
is_page(2)
in_category(4)
is_home()
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.