By stephtek on
I am trying to figure out how to create rollovers and swap images in my template depending on what page you are on. Has anyone done this before?
I am trying to figure out how to create rollovers and swap images in my template depending on what page you are on. Has anyone done this before?
Comments
I am doing this right now.
I am doing this right now. unfortunately i am new to drupal and this would be my first real drupal programming.
anyway, i created custom menu_item function that uses images for menu items.
through it i assign the initual image. after that i define in css the active, hover attributes for that image.
the above information will help you do menu rollover. also there is a drupal API that will tell you the current page node ID. based on that node ID you can add check inside menu_item function to see if the current menu item you are creating is the page that you are accesing then you can change the initial default image for that menu item that will imply to the visitor that they are on that speciffic page.
i know this is nothing concrete like some php code but i am not that far yet, but i know for a fact the above solution will work as i am about 90% done with implementing it.
Sometimes something interesting appears on http://litwol.com
This is my first Drupal
This is my first Drupal site.. so I am a beginner too.
Can you show me some code examples? I am not 100% sure I get it.
I will put it up tomorrow
I will put it up tomorrow for you if you are willing to wait.
Sometimes something interesting appears on http://litwol.com
Yeah, that would be helpful,
Yeah, that would be helpful, Thanks!
Do you know if it is
Do you know if it is possible to swap the image to the active state depending on what navigation block is enabled?
If i understand you
If i understand you correctly, then yes.
please visit this page for demonstration: http://64.158.178.196/
sorry for taking this so long, but i restrain myself from posting a complete answer to your question untill i completely figure it out.
Sometimes something interesting appears on http://litwol.com
That is perfect.
That is perfect. Can you send me the code as to how you did that? Is that checking to see what block is visible or what page you are on?
I hope this code will be
I hope this code will be easy to use. if not then ask away.
1) template.php, add this code there.
2) create a file menu_item.tpl.php in your theme folder (the same folder where your template.php is), put this code in it:
3) create a javascript file of any name you want with this code in it (and make sure to link this js file to your page.tpl.php):
Then in your administer > menu, you create a menu, and add menu items to it.
also it is very important to keep the file structure correct so this code knows where to get the images from.
themes/
....[your theme]/
...........images/
................menu/
...................menu_name/
......................page_title/
...........................menu_name.jpg <<
my images have the regular state, the "_on" and "_over" state. you can choose your own indicators and i'm sure you can edit the code to reflect yoru naming standards.
when everything is setup (menu created and menu items assigned in the admin, files and folders placed correctly) you will need to go into administer > blocks and assign your menu to some block in your theme and it will show up.
i will not go into theming your menu (as in position between images and other css stuff), i'm sure you can figure out the css (i'm still puzzled by it)
I hope i didnt leave anything out. feel free to ask.
Sometimes something interesting appears on http://litwol.com
OK, I am only slightly confused
OK, I am only slightly confused...
1. I dont have a file called template.php, I use page.tpl.php. Do i just insert the code in the head?
2. How do I link to a javascript file?
I am not using primary links, I have 6 top menu items (which are the images) that link to specific pages. I have created 6 seperate menus (administer > menu) that are displayed depending on what link from the top menu is clicked.
I am keeping all my menu images in a folder inside themes>hillside>images>menu. Do I need to change anything in the code to work with the way I have laid it out?
1) create the template.php
1) create the template.php like i told you, create the menu_item.tpl.php like i told you and make sure you palce the code i mentioned above in the correct files and put it in your hillside folder
2) if your javascript file is in the hillside folder then add this line to your page.tpl.php (make sure to put correct scripts.js file name)
3) you need to organize the menu images folder structure as i told you in my previous responce, my whole code is programmed around that structure...
4) admin menu configuration must be as i described. maybe i described it wrong, give me your drupal site url and admin login and i will help you configure it. use my contact form to mail me the login information.
Sometimes something interesting appears on http://litwol.com
Ok, I have set up my
Ok, I have set up my structure as follows:
themes/
....hillside/
...........images/
................menu/
...................menu_name (6 folders with each folder labeled after menu name)/
......................page_title (not sure what this would be, please advise)/
...........................menu_name.jpg (eg: contact_on.gif, contact_over.gif) <<
Let me know what page_title should be. Also, what is the code to insert into page.tpl.php that tells the menu where to load.
This is the site I am working on if that helps: http://hillsidecentre.com.wedodns.com/
PS: I am still learning Drupal, so I am a little slow.
page_title is your actual
page_title is your actual page.
so for example i have a page called "who we are", that is the title i gave it.
the folder will be named after the page name "who_we_are" and all the menu images that go for a speciffic menu and a speciffic page, they fall into that folder.
so for example if you have 2 menus on your page that is called "who we are"
one menu is called "my menu" and second called "some stuff"
then your file structure will be this:
themes/
....hillside/
...........images/
................menu/
...................my_menu /
......................who_we_are /
...........................menu_name.jpg (eg: contact_on.gif, contact_over.gif) <<
...................some_stuff /
......................who_we_are /
...........................menu_name.jpg (eg: contact_on.gif, contact_over.gif) <<
i hope that makes sence.
Sometimes something interesting appears on http://litwol.com
Oh ok.. So shopping, service
Oh ok.. So shopping, service etc are the names of my pages. I only have one menu so tell me if my structure seems correct now:
themes/
....hillside/
...........images/
................menu/
...................my_menu /
......................contact /
...........................contact_on.gif, contact_over.gif
......................events /
........................... events_on.gif, events_over.gif
......................leasing /
........................... leasing_on.gif, leasing_over.gif
......................renovations /
........................... renovations_on.gif, renovations_over.gif
......................service /
........................... service_on.gif, service_over.gif
......................shopping /
........................... shopping_on.gif, shopping_over.gif
i think i forgot to mention
i think i forgot to mention an important detail. due to my site's complicated design i had to keep the menu images for each button (i have 6 of them on my site) in each of the page folder.
so for example i have a page called "who we are"
so in there i will have images for menu items "who we are" "immigration help" "programs" etc etc.
and inside the immigration help page i will again repeat to have all those same images (not exactly the same but for the sakes of simplisity they are the same).
so in your care.
the contact folder holds not only the contact images, but also holds copies of events, leasing, renovations, service and shopping. each of the other folders hold the same images.
Sometimes something interesting appears on http://litwol.com
Oh ok.. so basically I have
Oh ok.. so basically I have to have all the nav images duplicated in each folder?
yes you are correct. while
yes you are correct.
while it may seem as a waste of space it still gives you more flexibility with your design.
for example on my site because the background image is different for each section of the site so the navigation images must be slightly different therefore they must have their own images for each of those pages.
Sometimes something interesting appears on http://litwol.com
hi
I am trying to find a way to make a vertical rollover menu, will this work? What would I need to change?
Could you tell me what this: "+ link+"/"+title+"/"+id+"_over.jpg will look like, like give me an example I am not quite following
This is really great, you should make a module that would upload the images to the right folders from the administation part of your drupal site.
Hello again
I am wondering if you managed to get it done the way i explained it.
Could you post your status here? i am still new to drupal and far from proficient with drupal development so i would hope to refine my methods based on your success of this project.
Sometimes something interesting appears on http://litwol.com
i´ve tried this and it
i´ve tried this and it worked perfectly, but when you got more than one taxonomy link in your navi, all taxonomy links get marked as active when you click on one of this. :(
cant see ur site at all
i am getting 504 error...
pls give me the link to ur site..thanks..are u using 5.1 Drupal ?
thanks
http://dev.hias.org
http://dev.hias.org
Sometimes something interesting appears on http://litwol.com