WordPress.org

Ready to get started?Download WordPress

Forums

Adding HTML to PHP (7 posts)

  1. SnowboardKid
    Member
    Posted 8 years ago #

    Hi all,

    Thankyou in advance.

    I've been fumbling my way around using wordpress and am having fun learning new things. Anyway, after much searching I figured out how to enable scrolling on IE in the admin section of wordpress (needed on my blog because I'm loading the whole thing in an iframe). All that is needed is to add the following code to the wp-admin/admin.php file (you may or may not need the head tags, I'm not sure).

    <head>
    <style>
    <!--
    body {
    overflow-y: scroll;
    }
    -->
    </style>
    </head>

    However, the admin.php file contains only one big <?php ?> and I know I can't add my html code after the ?> otherwise I get an error but I can't add it before the ?> because I get an error.

    So how do I add it to the admin.php file without breaking the php? I know there must be a valid open and close php tag that I can use after my inserted HTML that won't break it. Does anyone know what this is?

    Thanks once again,
    Rick.

  2. Samuel B
    moderator
    Posted 8 years ago #

    When adding html to a php file don't forget:
    <html>codecodecode</html>

  3. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    Hmm. Seems like you should just add this:
    body {
    overflow-y: scroll;
    }

    To the wp-admin.css file instead. It would have the same effect and you wouldn't have to screw around with the php code.

  4. SnowboardKid
    Member
    Posted 8 years ago #

    @ samboll: Thanks mate although it seems as though that makes no difference. It works without the <html> tag. If I add the <html> tag and paste my code before the ?> php tag it still errors out on me.

    @otto42: Thanks for the help. I just tried that and when I view a users profile it doesn't work in IE. Perhaps I need to add it another selector? your-profile perhaps? Why wouldn't it be applying to all?

    Thanks again for all the help.

    Rick.

  5. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    Well, if you want to try it your way, you'll need to edit admin-header.php. Find the <head> bit, and add this just after it:
    <style>
    body {
    overflow-y: scroll;
    }
    </style>

    But don't add the /head or anything else.

    Still, I don't think that would make any difference. Putting it in wp-admin.css would be just as good, really. Maybe it doesn't do what you think it does. What are you hoping to accomplish here?

  6. SnowboardKid
    Member
    Posted 8 years ago #

    Otto42,

    Thanks so much for the help. I appreciate it. What I want to achieve with this bit of code is force there to be a vertical scroller in the admin section of wordpress. As my site (www.popmag.com.au) loads in an iframe this is crucial as by default, there isn't a scroll bar in the admin section wehn using IE. So when I ad:

    <head>
    <style>
    <!--
    body {
    overflow-y: scroll;
    }
    -->
    </style>
    </head>

    To the wp-admin/admin.php file I get a scroll bar exactly where it is needed. However, because the wp-admin/admin.php file is one big <?php ?> tag and I don't know how to add the HTML code to the PHP file without getting header return errors. This is what I need to know how to do.

    I've tried adding it to the CSS and the admin-header.php as you suggested and it doesn't work.

    Thanks again,
    Rick.

  7. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    Okay, the problem is that admin.php doesn't stand alone. It's just the opening part of the page. The actual Dashboard page is index.php. It includes admin.php, which sets up a bunch of stuff, then calls the admin-header.php, which starts the actual webpage. One of the things admin-header.php does is to include the wp-admin.css linkage, so any CSS that you want to do will work IF you put it in wp-admin.css. So if it doesn't work, then I don't know what to tell you. Your CSS is wrong. Simple as that, really.

    The short of it is that you CAN'T add code to admin.php like that. Not that code, anyway. The header is not in admin.php, it's in admin-header.php and that's all there is to it.

    Are you using some plugin that modifies the dashboard? Like the Tiger Admin thing or something?

    Also, if you have the admin page in a frame, then you would really want the scroll to apply to the frame, no? Not to the admin page itself.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags