Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Center area post/pages » Excerpts, Read more, Pagination »

Tables break the layout.


  #1  
Old Feb 1, 2010, 05:26 AM
djberriman
 
8 posts · Jan 2010
If a table is included in a post then when excerpts are listed in the home page, the table formatting is removed and you just get the data listed vertically which looks a mess.

I added the table/tbody/tr/td so that they are not stripped out and that works to an extent, except that sometimes the full table is included in the excerpt and sometimes its not, it doesn't appear to be at the correct number of excerpt bytes but some arbitrary place. When the full table is not output then the whole layout is corrupted as the table is not closed and the rest of the output appears as part of the table. Really I guess the code should include the full table and not break it half way once it has started output.

I also tried using the read more tag in the post to stop the table being included in the excerpt, this works but there is a bug/feature in that the read more tab is not included after except, it would appear this is because if there is not much text before that table. The code should honour the fact it has seen a read more tag and add a read more tag to the excerpt regardless of the amount of data put in the excerpt.

Any thoughts on how I might solve these issues, any chance of fixing the read more issue?

Duncan
  #2  
Old Feb 1, 2010, 05:41 AM
juggledad's Avatar
juggledad
 
23,631 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
what version of Atahualpa and WP?
Did you look at http://forum.bytesforall.com/showthread.php?t=3377
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #3  
Old Feb 3, 2010, 05:16 AM
djberriman
 
8 posts · Jan 2010
Wordpress Version 2.9.1
Atahualpa 3.4.5.1

Regards
Duncan
  #4  
Old Feb 3, 2010, 07:21 AM
juggledad's Avatar
juggledad
 
23,631 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
and did you look at the post?
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #5  
Old Feb 4, 2010, 03:13 AM
djberriman
 
8 posts · Jan 2010
I did look at the post but it doesn't seem relevant. I am using method 2.

This is a different issue to do with tables.

If tables are used then the excerpt ends up a mess as you just send up with lines and lines of data one after another as the tags are stripped out.

If you stick a more tag into prevent this, there is no read more on the excerpt to entice the visitor to see the table/content.

If you tell it not to strip table, tr and td then it breaks at some point in the table and then the whole page layout is broken as there is no closing table tag.

It appears from what you are saying is I could manually add an excerpt and then 'fix' the read more code.

It would be better if we could fix the problem as its very likely to confuse others too.

All it really needs to do is honour the more tag that has been placed in the page and that will solve the issue. Not sure if thats a wordpress or a template issue.

I might have a play and see if I can fix the code
  #6  
Old Feb 4, 2010, 03:47 AM
djberriman
 
8 posts · Jan 2010
This appears to solve the issue for tables....

PHP Code:
// Custom Excerpts 
function bfa_wp_trim_excerpt($text) { // Fakes an excerpt if needed
    
    
global $bfa_ata;
    
$addmore 0;

    if ( 
'' == $text ) {
        
$text get_the_content('');
        
// tables break layout so don't display in excerpt
        // force read more as there is more to read
        
$addmore strpos($text,'<table');
        if (
$addmore !== false) {
            if (
$addmore 0)  {
                
$text substr($text0$addmore 1); 
            }
            else {
                
$text '';
            }
        } 
        
$text apply_filters('the_content'$text);
        
$text str_replace(']]>'']]>'$text);
        
$text strip_tags($text$bfa_ata['dont_strip_excerpts']);
        
$excerpt_length $bfa_ata['excerpt_length'];
        
$words explode(' '$text$excerpt_length 1);
    } else {
        
$words explode(' '$text);
    }

    if (
count($words) > $excerpt_length || $addmore) {    
        if (
count($words) > $excerpt_length) {
            
array_pop($words);
        }    
        
$custom_read_more str_replace('%permalink%'get_permalink(), $bfa_ata['custom_read_more']);
        
$custom_read_more str_replace('%title%'the_title('','',FALSE), $custom_read_more);
        
array_push($words$custom_read_more);
        
$text implode(' '$words);
    }

    return 
$text;

I did try to scan for the read more tag but I think it is stripped before calling this function.

Duncan

Last edited by djberriman; Feb 4, 2010 at 04:27 AM.
  #7  
Old Feb 4, 2010, 05:06 AM
juggledad's Avatar
juggledad
 
23,631 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
This whole excerpt this is a can of worms. What if I stuck a more tag in the table?
This is a problem with excerpts in WordPress. WordPress strips ALL HTML tags,. This is from http://codex.wordpress.org/Template_Tags/the_excerpt

Quote:
Displays the excerpt of the current post with [...] at the end, which is not a "read more" link. If you do not provide an explicit excerpt to a post (in the post editor's optional excerpt field), it will display a teaser which refers to the first 55 words of the post's content. Also in the latter case, HTML tags and graphics are stripped from the excerpt's content. This tag must be within The Loop.
If you have a complicated post, hand craft the excerpt, that takes precedence
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #8  
Old Feb 4, 2010, 06:00 AM
djberriman
 
8 posts · Jan 2010
If I added a read more in the middle of a table I'd get what I expected eg a mess so I wouldn't do it and if I did I would know how to fix it by removing the tag.

Whereas simply having a table in a post currently either looks a mess and a new user of wordpress might not realise why which is what happened to me for quite a while until I figured out the reason.

Similarly if you tell the theme not to strip the table tags then it may or not break the page depending on the size of the table. It just depends where the break happens to land in the table or outside it.

In my case there is no real excerpt to manually post as it is simply a set of results for a competition and its an extra job to do and remember to do to post the excerpt. If you forget your website looks a mess.

The above fix ensures that any excerpt will not break the page by ensuring tables are not displayed.

It works for me and anyone else is obviously welcome to use it if you decide its not worth putting in the standard theme.
  #9  
Old Feb 4, 2010, 08:38 AM
juggledad's Avatar
juggledad
 
23,631 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
I told you this is a can of worms - your fix has an error. Use this as a post
HTML Code:
one two three<table><tr><td>table 1 - cell 1</td></tr></table> fout five six
<table><tr><td>table 2 - cell 1</td></tr></table> seven eight nine ten elevin twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty
and set the excerpt at 5 then look at the results. You get 'one two thre'
now set it at 15 and look at the results, you still get 'one two thre'.

If you feel that tables should be excluded from an automatic excerpt, then you need to change the code so it would return some thing like (in case 1) 'one two three ** excluded table * four five readmoreatxxxxx'

and with the excerpt at 15 you should get 'one two three ** excluded table * four five six
** excluded table ** seven eight nine ten elevin twelve thirteen fourteen fifteen readmoreatxxxxx
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #10  
Old Feb 4, 2010, 09:40 AM
djberriman
 
8 posts · Jan 2010
I did not understand your post #7, perhaps if you re-read it you will see why.

As for you last post there is NO error - An error suggests it does not work as designed or the code falls over or fails in some way.

The code works as I suggested it does - it uses everything up to the first table as the excerpt.

It was not designed to strip out tables as you suggest. That would require a lot more code, a loop and more processing for very little gain IMHO. Clearly it would not be complex to do.

I thought I was been helpful by contributing some code, clearly given your reaction perhaps I should not have bothered.
  #11  
Old Feb 4, 2010, 10:05 AM
juggledad's Avatar
juggledad
 
23,631 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
I'm am so sorry if I've caused you any offense. I never meant to, I was just trying to carry on a dialogue about this issue. I've spent some time on it and know how complex it is.

The Atahualpa code trys to give more control than the embedded WordPress excerpt function. That code stripes all HTML and then uses the remainder to create the excerpt. This works great for the simple cases but falls down on the complex cases.

Your suggestion does fix 'a' situation (with the excepton of losing that last character if the you have 'word<table>', it will work if it is 'word <table>') I just wish I could figure out a way to solve this for all cases. I took a long looked at this code and did the best I could. As you said, there are so many cases that you would need to test for and then the mixing of cases where there is a read more tag before the excerpt limit or tables or image code or shortcodes that get expanded. (I should probally change teh title of the other post from 'Getting Configure Excerpts to work in all cases' to 'Getting Configure Excerpts to work in almost cases'

Once again I am truely sorry if I came across in a negative or offensive way, it was not my intension and I hope you will forgive me.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #12  
Old Feb 4, 2010, 10:23 AM
djberriman
 
8 posts · Jan 2010
No worries........! All forgiven, its always easy to take offence when its not intended. I should know I've done it enough times myself.

You are quite correct on your last point, the -1 in following line is not required.

$text = substr($text, 0, $addmore - 1);

it should just be

$text = substr($text, 0, $addmore);

I thought I'd got it right and tested it but there was a line break in my test so I did not spot the potential issue. Thanks for pointing that out. You are also correct in pointing out that it might miss tables due to case.

I had a quick look at removing the tables and although its possible it would require a lot more code and logic for little gain. My main concern was to stop it corrupting the page or making it look very odd.

I guess this is just one for those who need it for now until something better can be developed.

PS. I love this theme, I host and maintain a few sites for free for a number of clubs I am a member of and it makes life so easy and produces such an impressive site for so little work (on my part).

Thanks for all your help.

Duncan

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Footer: How to add line break in footer text StudioGal Post-Kicker, -Byline & -Footer 2 Oct 9, 2009 06:41 AM
[SOLVED] Layout WIDTH vs. Layout Container Olivier Header configuration & styling 2 Jul 13, 2009 06:18 PM
Using tables??? jim Excerpts, Read more, Pagination 1 Jun 4, 2009 06:04 PM
Using tables Ron Atahualpa 3 Wordpress theme 20 Mar 29, 2009 03:11 PM
Update to latest version - will it break? bergonzzi New Versions, & Updating 1 Jan 28, 2009 04:21 PM


All times are GMT -6. The time now is 10:27 PM.


Powered by vBulletin® Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.