TK3 Posted August 1, 2013 Share Posted August 1, 2013 I am having problems checking when a textarea field is empty. I have a field called "body" which has no input filters and is a standard textarea (not richtext). When I don't enter anything in this field I get the following when I retrieve $page->body <span class="offset" style="margin:0;padding:0;position:absolute;width:0px;height:0px;"> </span> How can I check if this field is empty so that I can prevent this output with an if statement? Link to comment Share on other sites More sharing options...
kongondo Posted August 1, 2013 Share Posted August 1, 2013 Hi TK3. Welcome to PW and the forums! That's strange. PW does not output any markup. Is that your markup? What version of PW is that? To check if your body field is empty is as simple as if ($page->body) { echo $page->body; } In a selector, to find other pages where body is not empty you can do this... $pages->find('template=sometemplate, limit=20, body!=""'); 1 Link to comment Share on other sites More sharing options...
TK3 Posted August 1, 2013 Author Share Posted August 1, 2013 Processwire 2.3.0 Link to comment Share on other sites More sharing options...
kongondo Posted August 1, 2013 Share Posted August 1, 2013 Like I said, that looks strange and I have never seen it before. Could you please give us more information, e.g. are you using the default PW install? Have you made modifications to its template file(s)? How does your code around that selector ($page->body) look like? etc.. Link to comment Share on other sites More sharing options...
TK3 Posted August 1, 2013 Author Share Posted August 1, 2013 Actually I just now confirmed that it's inserting that <span> stuff on the $page->body output regardless of being empty or not. I am using a Textarea type input, Textearea inputfield, with no text formatters. This is very weird. I have not made any modifications other than adding my own templates. Could some plugin be causing this? Link to comment Share on other sites More sharing options...
kongondo Posted August 1, 2013 Share Posted August 1, 2013 (edited) TK3, It is very hard to debug without more information. Please post: Using the forum code utility, the code in your template file around the problem area Details of the modules you have installed (though I don't think this is the problem) If you have a test site (front-end) that we can look at, you can post a link here too In your TEST site (local not remote), turn on debug in your /site/config.php. Are there errors reported when you load the page with the empty body? Check your /site/assets/logs/errors.txt file. Any errors reported? Do you get errors/weirdness with other fields? E.g. rich text area field? What if the field is not empty, do you still see the <span> in the output/source? Are you using the default ProcessWire install or are you using some other profile? (Foundation, Bootstrap, etc.) It could be coming from some Javascript. Are you using some JS in that template file? Edit: Searching your output above Google has led me to the module ProcessHeatmap (Heatmap by Userclicks). Are you using that? See below code from here public function setOffset(){ //we assume that the $page->body is inside main layout and add a span //hidden span indicates offset left to make fluid layout handling possible $this->page->body .= '<span class="offset" style="margin:0;padding:0;position:absolute;width:0px;height:0px;"> </span>'; } Edited August 1, 2013 by kongondo 5 Link to comment Share on other sites More sharing options...
diogo Posted August 1, 2013 Share Posted August 1, 2013 Using your output above Google has led me to the module ProcessHeatmap. Are you using that? spot on Link to comment Share on other sites More sharing options...
TK3 Posted August 1, 2013 Author Share Posted August 1, 2013 Thanks guys! I was using this module. I have uninstalled. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now