• Resolved Doodlebee

    (@doodlebee)


    I had another post earlier today, and this has a bit to do with that one – except circumstances have changed. Iwasn’t sure if it owuld be better to start a whole new thread (they have changed that much) or reply to the other one – so I flipped a coin and “new thread” won.

    So, here’s the situation: I have a *seriously* customized sidebar. The way things are going, it’s getting out of control – my sidebar file is immense. There has to be a better way of doing this.

    I’m using WordPress as a CMS. There are many *many* pages and subpages. Last count was around 50 Pages (this count is including the subs – there’s about 7 parents). Now, the client has requested that all of the links be *images* not text. Okay, I’ve gotten around that – I’ve just been placing images in the titles of the Pages, rather than text. However, because of the serious customization going on, I’ve had to abandon the use of the get_pages() list to call in the sidebar links, and instead, I’ve had to hand-code each link. This is getting to be a real PITA. And if the client ever adds a new page…agh. They’ll never figure out how to put the new link in.

    The reason for the major customization is this (i’m going to list it, trying to be as clear as I can):

    The list is a CSS-based hover list. When you mouseover the links, it’s like a javascript image swap – but it’s total CSS, no javascript needed. The thing I require for this to function – that the get_pages() list doesn’t give me – is that each link has its own ID. This is necessary for the links to work (the way it works is the background for the LI tag is the “on” state for the image. But the “off” state image is placed within the LI tag, hiding the background. Then you set a “display:none” in the stylesheet for the hover of the link, and it looks like an image swap, when in reality it’s just the image disappearing from view and exposing the background. Since each background image is different, each link has to have it’s own ID.)

    Now the kicker is, I also have to have a current page and home page state for each link as well. So this sidebar coding is getting WAY out of control. I’ve been toying with ideas on how to get this to function, but I’m coming up blank – there *has* to be a better way to do this – one that simply allows the client to create a new Page, and the new link just shows up in the sidebar (or delete an old one and the link goes away).

    If only they didn’t want so many hover states and images – argh! Would anyone have any ideas or suggestions on how to get this to work?

    Or, alternatively, if I write a function to place in the wp_meta(), would that work? If I did that, could I save the function as a seperate file and call it in? What would I have to do to get that to work? (OMG, am I talking about writing my first plugin without even knowing it?!?)

    I’d really appreciate any help you all could give. I gotta have this done by Monday morning (not that this is *your* problem, but it’s such a headache!)

Viewing 15 replies - 1 through 15 (of 21 total)
  • A php function which increments each post title by 1 and produces the appropriate id/image etc?

    I dunno…. that’s ugly, having to have something client-usable by Monday….

    Thread Starter Doodlebee

    (@doodlebee)

    Yes, I know.

    I *did* find nice little plugin:

    Fold Page List Plugin – the problem is that it doesn’t allow for images. If the client would *allow* me to use text instead of images for the sidebar links, this would make it a breeze to use (hell I could do it withouth the plugin if the client would go for text over images) but that’s a no-go.

    I’m wondering if I can modify this plugin to allow for the images. One thought I had – don’t know if it will work – if is I can somehow use PHP to convert the Page names into classes and then apply that as a variable. For example, if I had a page named “About Us”…I could enter that text as the title of the page name. Then the PHP code would do something like

    <li class="<?echo $page_name(); ?>"><a href="<?php page_link(); ?><img src="images/<?php echo page_name(); ?>.gif"></a></li>

    I’m pretty sure this would work – the problem would lie in the space – “About SPACE Us” – converting that space into an underscore would be *extremely* helpful.

    This has become a major headache. (little vent there!) Would you (or anyone) think that would work? Any suggestions on how to do that?

    Well, for as much as I know about it, yes – that sounds as if it would work. I, however, am VERY FAR from being any kind of programmer – so I haven’t a clue if your code is what’s needed or not.

    There should be something around at one of the major php “helper” sites which can do that space-to-underscore magic….

    Um…. a function of some sort which changes “About ‘space’ Us to AboutUs? Problem would be when the client does something truly weird like “We’re ‘space’ Giving ‘space’ Away ‘space’ XXXXX” or something….

    the problem would lie in the space

    Not if you use the post_name record value for the Page. That is the url-encoded form of the Page title: About Us turns into about-us. You also have a function at your fingertips:

    sanitize_title("$page_name");

    sanitize_title() is the WP function which performs Title to url-ized conversion.

    Hah! See, if Kafkasquí’s around, you surely don’t need me! And I am now copying this whole thread to file, because I bet I wind up with something similar with one of my clients eventually!

    Believe me v, we still need you around… ;)

    Thread Starter Doodlebee

    (@doodlebee)

    ooo…promising. Kafka – at this moment, I want to bear your children. LOL

    I’m gonna have to try this. I’ll let you know how it goes!

    As I said, I have copied the whole thread to file. So doo-bee…. please be sure to post back as it goes along, and I’ll add to the whole file.

    Then we can collaborate it up on codex….

    [Thank you Kafkaesquí – I appreciate the sentiment.]

    With the comments to v and Kaf, there is a lot of love in this thread. Holy cow, are we still PG? 😉

    [and I agree with Kaf, we needs ya, vkaryl!]

    Um…. whooo…. okay, guys – enough. I never intended to leave entirely. Just some of the “overhead” was too much.

    I like helping. I’ll be around.

    Thread Starter Doodlebee

    (@doodlebee)

    okay – I wanted to give you a breif update. I got the li class to change by opening up my “wp-includes/template-functions-post.php” file. I found this line:

    $css_class = ‘page_item’;

    and changed it to this:

    $css_class = sanitize_title($title);

    and now my li classes reflect my page titles with “_” between the words – so “About Us” (as the page title) shows up as <li class="about_us">

    It’s a beautiful thing.

    Now, this *alone* will work on the site I’m working on, because they won’t be using WordPress for multiple stuff – just the one site. However, now I’m wondering if there’s a way to write some kind of plugin or function or something that could change that line depending upon the theme you’re using, rather than hacking up a core file.

    There’s more I have to do (if I can figure out how to make this work so the *stylesheet* is dynamic and I won’t have to write out every single image for every single link, I’ll be in hog heaven!) – so I’ll keep updating as I figure stuff out – but if someone knows how to do what I’m doing *externally* (rather than hacking core) that would be awesome.

    (and as a side note – glad you aren’t quitting altogether vkrayl – your username always made me think of the “valkylrie”, one of my favorites in mythology! Don’t know if that was on purpose from your side or not, but I always see your name and think of a metal bustier and a helmet with the horns coming out of it- a la Bugs Bunny! “Kill the Wabbit!” LOL)

    Oh good LORD. They want a NEW image for EVERY title? Sheesh…. I’m glad this is YOUR client and not mine. I’d have already done something irrevocable…. But what you’ve got so far is REALLY schweet! Kaf is such a bright guy….

    [*laughing* I have actually used variations of “valkyrie” in my fiction for years…. though “vkaryl” as username is an amalgam of my first initial and a phoneme of my middle name.

    Heh…. well, I’ve “horns” on the mule deer racks on the walls, and I guess my .270 can be considered a “sorta” spear…. I used to sing (high school – 40+ years ago!) but Brunnhilde I’m not….]

    Thread Starter Doodlebee

    (@doodlebee)

    Oh good LORD. They want a NEW image for EVERY title?

    Hell yes they do. otherwise, this would be cake 😉

    But it’s working *great* so far! Ialso have to edit the admin pages so they know that, whatever they name the Page, they have to name the title of the image as well – *exactly*. (Yes, I’ve been editing their admin area with instructions so they won’t get all confused. I swear, I need to raise my prices!)

    I have a hard time visualizing how a million different images instead of real words is going to help their readers…. but that’s just me….

    Glad you’re getting it sorted though!

    Thread Starter Doodlebee

    (@doodlebee)

    Yeah – well, they’re using the text for the actual titles of the pages (I forgot about that – just one more fun thing to work on!), only the sidebar is made up of images.

    So here’s a question. I’m trying to create a dynamic stylesheet to call in all the images and styles. I’ve got the stylesheet working in gerneral, but I can’t figure out how to call in the names of the Pages into it.

    Would anyone know how to do that? What is the actual PHP thing you’d put in to “echo” the Page slug, or the ID I had created for the LI tag? I hope that makes sense…

Viewing 15 replies - 1 through 15 (of 21 total)

The topic ‘seriously customized sidebar’ is closed to new replies.