keighdesign Posted September 30, 2011 Share Posted September 30, 2011 I want to limit the length of an author's name in a display to 10 characters - using two lines if necessary for full display. I know I can use wordwrap of some sort to do that. However, I am not sure where/how to accomplish it. Can it be inserted in the following (and if so, where/what do I insert, specifically): <?php _e('Order by','authors') ?>:<br /> <label for="authors-order-<?php echo $number; ?>-name"><input type="radio" class="radio" id="authors-order-<?php echo $number; ?>-name" name="widget-authors[<?php echo $number; ?>][order]" value="name"<?php echo 'name' == $order || '' == $order ? ' checked="checked"' : '' ?> /> <?php _e('Display name','authors' ) ?></label> NOTE: I have attached the full code in a text file if I've selected the wrong snip. Thank you! [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/248200-where-to-insert-wordwrap-in-php-file/ Share on other sites More sharing options...
keighdesign Posted September 30, 2011 Author Share Posted September 30, 2011 UPDATE: I HAVE ATTACHED AN IMAGE FILE THAT SHOWS THE CURRENT PROBLEM IN DISPLAY I want to limit the length of an author's name in a display to 10 characters - using two lines if necessary for full display. I know I can use wordwrap of some sort to do that. However, I am not sure where/how to accomplish it. Can it be inserted in the following (and if so, where/what do I insert, specifically): <?php _e('Order by','authors') ?>:<br /> <label for="authors-order-<?php echo $number; ?>-name"><input type="radio" class="radio" id="authors-order-<?php echo $number; ?>-name" name="widget-authors[<?php echo $number; ?>][order]" value="name"<?php echo 'name' == $order || '' == $order ? ' checked="checked"' : '' ?> /> <?php _e('Display name','authors' ) ?></label> NOTE: I have attached the full code in a text file if I've selected the wrong snip. Thank you! [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/248200-where-to-insert-wordwrap-in-php-file/#findComment-1274519 Share on other sites More sharing options...
requinix Posted September 30, 2011 Share Posted September 30, 2011 So the actual problem is the size of the , yes? Can you not use CSS to restrict, or even flat-out declare, its width to fit appropriately? Link to comment https://forums.phpfreaks.com/topic/248200-where-to-insert-wordwrap-in-php-file/#findComment-1274521 Share on other sites More sharing options...
keighdesign Posted September 30, 2011 Author Share Posted September 30, 2011 So the actual problem is the size of the <select>, yes? Can you not use CSS to restrict, or even flat-out declare, its width to fit appropriately? This is a widget inside the latest version of Wordpress. CSS would have to be inline. Would I add the css in this section? I am not a php coder and am hesitant to start hacking around inside it. Please advise and thank you so much for your time. function widget_authors_dropdown($args = '') { $args['echo'] = false; unset($args['feed']); $arr = widget_authors_order_by($args); $options = ''; foreach ($arr as $author) { preg_match('#<a href="([^"]*)"[^>]*>([^<]*)</a>( \(([0-9]*)\))?#', $author, $matches); $options .= '<option value="'.htmlspecialchars($matches[1]).'">'.$matches[2].($args['optioncount'] ? ' ('.$matches[4].')' : '').'</option>'."\n"; } unset($arr); $dropdown = '<select onchange="window.location=this.options[this.selectedIndex].value">'."\n"; $dropdown .= '<option value="#">'.__('Select Author...', 'authors').'</option>'."\n"; $dropdown .= $options; $dropdown .= '</select>'; echo $dropdown; } Link to comment https://forums.phpfreaks.com/topic/248200-where-to-insert-wordwrap-in-php-file/#findComment-1274530 Share on other sites More sharing options...
requinix Posted September 30, 2011 Share Posted September 30, 2011 Would I add the css in this section? $dropdown = ''."\n"; Right in there. For example, $dropdown = ''."\n"; Link to comment https://forums.phpfreaks.com/topic/248200-where-to-insert-wordwrap-in-php-file/#findComment-1274535 Share on other sites More sharing options...
keighdesign Posted September 30, 2011 Author Share Posted September 30, 2011 It worked perfectly!! Thank you! Would I add the css in this section? $dropdown = '<select onchange="window.location=this.options[this.selectedIndex].value">'."\n"; Right in there. For example, $dropdown = '<select style="display:block;width:100%;" onchange="window.location=this.options[this.selectedIndex].value">'."\n"; Link to comment https://forums.phpfreaks.com/topic/248200-where-to-insert-wordwrap-in-php-file/#findComment-1274543 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.