WordPress.org

Ready to get started?Download WordPress

Forums

Help with AJAX (7 posts)

  1. mamouneyya
    Member
    Posted 3 years ago #

    Hello everybody,

    I am about to finish building a child theme for P2. I am not interested in changing any of the functionalities since it's just perfect for my use.. so it's all about the look and feel.

    To make the post box looks special, I had to add some divs/spans around the main < li > element in entry.php. The final result is something like:

    <span class="my-post-topedge"></span>
    <li id="prologue-<?php the_ID(); ?>" <?php post_class( get_the_author_meta( 'ID' ) ); ?>>
    
    	<div class="my-post-leftedge">
    	<div class="my-post-content">
    
    		<?php if ( !is_page() ) : ?>
    ...
    
    		<?php endif; ?>
    
    	</div> <!-- .my-post-content -->
    	<span class="my-post-bottomedge"></span>
    	</div> <!-- .my-post-leftedge -->
    
    </li>

    As you can see, there is a span outside that shows the top edge of the box, plus two divs inside that show the left edge and the background for the box content, respectively. (yes, you guess it! the right edge is the li's background it-self) Finally, there is a span at the end that shows the bottom edge of the box.

    The problem now is the AJAX, which I really have no idea about, unfortunately. When adding a new post, the only element that is being load is the < li >, without all of the others divs/spans. As a result, the loaded post looks horrible without refreshing the page.
    If there was an easy change I can made to make it loads those elements, then I will really appreciate if anyone let me know about it. Otherwise, I'll have to live with it!

    Thanks!

  2. Dunno why you tagged it for me. I'm not an AJAX expert by any means (nor do I acutally use P2.... nor am I the worlds best themer... that would probably be Esmi, when it comes to theme support ;) )

    Untagging cause I don't know either.

  3. esmi
    Forum Moderator
    Posted 3 years ago #

    It sounds like you'd have to amend the AJAX script to some extent. But, personally, I think your current code looks like it's suffering from divitis. I don't know P2 at all but I'd be curious to see the output without your extra divs and spans. There may be existing hooks that you could re-use - otherwise you could be in for a lot of Ajax re-editing.

  4. mamouneyya
    Member
    Posted 3 years ago #

    @Ipstenu I am sorry. I thought you can help. Anyway, thank you for bringing the expert :P

    @esmi Here is the original file (entry.php):
    [Code moderated as per the Forum Rules. Please use the pastebin]

    As you can see, there is a new div! That is because I found later that I need to assign a special background to the li element when using the key shortcuts feature of the theme (there are shortcuts to go through the next/previous post, which need some highlight effect for the post you chose).

    Thanks!

  5. esmi
    Forum Moderator
    Posted 3 years ago #

    I need to see the site itself.

  6. mamouneyya
    Member
    Posted 3 years ago #

    Just sent you an email.

  7. mamouneyya
    Member
    Posted 3 years ago #

    Sorry to be annoying, but did you have any chance to check it?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags