Jump to content


Photo

How to find elements with empty field


  • Please log in to reply
23 replies to this topic

#21 Soma

Soma

    Hero Member

  • Moderators
  • 5,051 posts
  • 3818

  • LocationSH, Switzerland

Posted 14 February 2012 - 04:32 PM

code also checked, even in new file.


Only new file and copied over? Have you tried rewrite the line of code that causes the issue from scratch? You laugh, but I got an situation where it just wouldn't work with a selector, turned out there was a hidden char not visible at all even in "showinvisible" mode.

@somartist | modules created | support me, flattr my work flattr.com


#22 elmr

elmr

    Jr. Member

  • Members
  • PipPip
  • 10 posts
  • 0

Posted 14 February 2012 - 05:08 PM

Soma I've rewritten the code and it was the same but...another strange thing.

I thought it may be connected with pager so I removed rendering pager, disabled page numbers for this particular page and changed code to :
$pages->find('template=movie, limit=10')->not("youtube_id=''");
But it didn't show any results.

So I removed limit=10 and then it worked properly. Movies with empty fields didn't show up. But still I didn't have pager functionality, so I brought back rendering pager, enabled page numbers and added limit=10 again... and now it's working right... with the code and the same settings with which it was not working few minutes ago.

It's really strange and I have no idea what can be the reason of this behaviour :-/

#23 ryan

ryan

    Reiska

  • Administrators
  • 7,797 posts
  • 6572

  • LocationAtlanta, GA

Posted 15 February 2012 - 04:08 PM

It's really strange and I have no idea what can be the reason of this behaviour


Any time when I've had behavior like this it's because I was using either template caching or markup caching, and didn't realize I was seeing cached versions. So make sure you are logged in when changing around stuff (or that you aren't using caching).

We've also noticed that TinyMCE can store characters in text fields that aren't otherwise visible (even looking directly in the database). I had to go in with a hex editor before I could see the UTF-8 non-breaking space TinyMCE had inserted. So if your text field has been used with TinyMCE at some point, that's something to consider.

Table repair is also something to consider when you see strange results. That will cause MySQL to rebuild the index for the table. But I wouldn't expect this to be necessary unless someone has changed a MySQL setting (like ft_min_word_len) and not rebuilt all the database indexes.

#24 owzim

owzim

    Sr. Member

  • Members
  • PipPipPipPip
  • 159 posts
  • 115

  • LocationBerlin, Germany

Posted 01 August 2013 - 03:42 PM

I was just encountering the same problem but with another root of evil =)
 
I used it on a date field like: 

$pages->find("date_field!=''")

for finding pages with non empty date_fields, but it turns out, the selector engine is using the unformatted value of the fields (what else, silly me), in this case the value of an unformatted date_field is 0 and not "" (empty) which is what it looks like on the admin page.

So

$pages->find("date_field!=0")

works just fine.


@owzim | ch.rauni.me | "We want a panther, not a pig." ~ Ryan Cramer




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users