3 of 6
3
Checkboxes
Posted: 25 January 2007 12:48 AM   [ Ignore ]   [ # 37 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

@Michael: Custom profile fields are a little different, but certainly possible if you’re up for a little tinkering.  You’ll have to poke around in the /system/cp/ files and find the places to make changes as I’ve never really looked into this.  On the surface though I can’t imagine it would be too difficult.

@Seth: I’m still a little confused.  The tag isn’t a loop so there shouldn’t be any need (or possible way) to use the count.  You simply call {field_name} and it prints out ALL the selected checkboxes.  There’s no way to say something like {field_name}....{count}....{/field_name}.  Can you explain how you’re using the count?  My initial guess is that you’re seeing the count of the weblog entry the field is in and not the count of the checkboxes.

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 25 January 2007 10:07 AM   [ Ignore ]   [ # 38 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  183
Joined  03-21-2006

Sure,

I am trying to fix an IE6 bug and for some reason the from the third box down there is a 3px bump to the left and I have a special class that fixes that.  So I was trying to use count to give that style to the items if they went above the second one. 

So it would look like this.

<ul>
    <
li>Item 1</li>
    <
li>Item 1</li>
    <
li class="threepx">Item 1</li>
    <
li class="threepx">Item 1</li>
    <
li class="threepx">Item 1</li>
</
ul>

 Signature 

http://www.sethaldridge.com/

Profile
 
 
Posted: 25 January 2007 11:07 AM   [ Ignore ]   [ # 39 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

can you show me the EE tags you’re using to create that list?  In your previous example each li was printed explicitly, not in a loop so you could just apply the class directly to that <li>.

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 25 January 2007 11:29 AM   [ Ignore ]   [ # 40 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  183
Joined  03-21-2006

This is how it is currently set up:

<?php ob_start(); ?>{development}<?php $str=ob_get_contents();ob_end_clean(); if(strpos($str, "Web Design")!==false): ?><li><a href="http://www.re-volvemedia.com/services/development/web-design/">Web Design</a></li><?php endif; ?>

I then created a simple If statement like this:

{if count > 2}
     
     PHP line from above with added
class

{if:else}

     PHP line from above
as is

{
/if}

When I used that it would count the total number and if the total number was greater than 2 it would add the class to all items displayed and vice versa.

 Signature 

http://www.sethaldridge.com/

Profile
 
 
Posted: 06 February 2007 07:39 AM   [ Ignore ]   [ # 41 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

Seth, sorry I’ve been so slow to get back to this.  I think I’m beginning to understand though.  The last bit of confusion is “what does {count} count?”

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 06 February 2007 07:46 AM   [ Ignore ]   [ # 42 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  183
Joined  03-21-2006

Mark,

Thanks for taking the time to keep looking into this.

I’m sure that I’m using it incorrectly, but in the docs this is what it says:

“You could use this to apply different styles to the first entry or have the last 5 entries out of 10 be formatted differently.” but it refers to entries rather than physical items.

I was trying to get {count} to count the total number displayed between the {if} conditionals.  But that is not how it is used.

I’m not sure if that makes more sense.

Thanks,
Seth

 Signature 

http://www.sethaldridge.com/

Profile
 
 
Posted: 06 February 2007 07:58 AM   [ Ignore ]   [ # 43 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

I see.  The {count} tag displays the number of the entry being displayed.  It has no bearing in regards to the fields within the entry.  If you’re trying to get the number of items in a checkbox field, you may be best off using PHP.  Something like this may work:

<?php

ob_start
();
{checkbox_field_name separator="\r"}
$data
= preg_split('/[\r]+/', ob_get_contents());
ob_end_clean();

$count = count($data);

?>

Of course then it would be up to you to structure your field display into that code.

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 21 February 2007 02:18 PM   [ Ignore ]   [ # 44 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  491
Joined  09-16-2004

I must be missing something crucial here but I just can’t get the extension to output the chosen checkbox values from the weblog entry.  I’ve called my checkbox custom field ‘sizes’, and the checkboxes appear in the entry form.  I’ve also placed {sizes} in my template, within the weblog:entries tag - which incidentally is displaying all other custom field content.  But nothing appears in the rendered page, just blank. 

Am I missing something?  Many thanks : )

 Signature 

Definition // Simply effective websites - web design based in Hull and East Yorkshire

Profile
 
 
Posted: 21 February 2007 02:52 PM   [ Ignore ]   [ # 45 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  491
Joined  09-16-2004

And now it’s doing it without a hitch.  Grrr…

Sorry : )

 Signature 

Definition // Simply effective websites - web design based in Hull and East Yorkshire

Profile
 
 
Posted: 28 February 2007 09:57 PM   [ Ignore ]   [ # 46 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  774
Joined  07-18-2006

Someone else asked and I didn’t see a reply - is there a way to get this to work with a SAEF?  I have to use checkboxes in a variety of SAEFs and I need some field in the CP that will accept multiple values. This doesn’t seem to work as is - did anyone find way to make it work?  Or barring that - is there ANY CP field that will accept multiple values from a list of some sort?

Any replies greatly appreciated (deadline fast approaching).

Thanks!

Profile
 
 
Posted: 01 March 2007 07:13 AM   [ Ignore ]   [ # 47 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  774
Joined  07-18-2006

To follow up on my own question tongue laugh

I had a bit of sloppy coding that wasn’t allowing it to work. This DOES work using a SAEF as long as you name the field correctly.  You have to name the field in the form to accept multiple selections but adding [] to the end.  So if you’re looking at field 19, the field name should be field_id_19[].

I’m not using the auto-generation of fforms, I’m building my form manually, so I’m not sure if it works when you auto-generate the form…

Profile
 
 
Posted: 01 March 2007 08:48 PM   [ Ignore ]   [ # 48 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  774
Joined  07-18-2006

Question - in the CP when you’re setting up the custom fields and choose checkbox, the ‘textarea rows’ field shows.  It doesn’t appear to do anything.  Does that do anything or is it just there hanging out?

Profile
 
 
Posted: 13 April 2007 01:14 PM   [ Ignore ]   [ # 49 ]  
Grad Student
Rank
Total Posts:  90
Joined  02-26-2007

ok. i have the ext.checkbox.php and the lang.checkbox.php.. now how or where do i drop these? i have the lang.cehckbox.php in the lang/english/ dir and the ext. in the externtions dir. but when i try to add a custom field. the checkbox option doesnt show.. can i get some help (=

Profile
 
 
Posted: 13 April 2007 01:51 PM   [ Ignore ]   [ # 50 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  774
Joined  07-18-2006

Did you enable the extension in the utilities->extensions area?

Profile
 
 
Posted: 13 April 2007 02:19 PM   [ Ignore ]   [ # 51 ]  
Grad Student
Rank
Total Posts:  90
Joined  02-26-2007

ya. its enabled. but when i go to the custom field to add a new field. the field type only show the original 3 fields. not the checkbox.

Profile
 
 
Posted: 13 April 2007 03:05 PM   [ Ignore ]   [ # 52 ]  
Grad Student
Rank
Total Posts:  90
Joined  02-26-2007

is this extention used in the Custom Profile Fields? or this extention is for something else?
i only see “Text Input”, “Text Area”, “Drop-Down Menu”. where is checkbox?
please help out.

Profile
 
 
Posted: 16 April 2007 12:07 PM   [ Ignore ]   [ # 53 ]  
Grad Student
Rank
Total Posts:  90
Joined  02-26-2007

can someone give me a hand on how to get the checkbox to work with the members custom form fields? thanks.

Profile
 
 
Posted: 16 April 2007 12:19 PM   [ Ignore ]   [ # 54 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  774
Joined  07-18-2006

I don’t think this can be used in conjunction with member custom form fields unfortunately - it’s for weblogs…

Profile
 
 
   
3 of 6
3
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64553 Total Logged-in Users: 29
Total Topics: 81156 Total Anonymous Users: 15
Total Replies: 436586 Total Guests: 181
Total Posts: 517742    
Members ( View Memberlist )