Tagged: html
-
AuthorPosts
-
February 27, 2015 at 10:48 am #403294
Hey,
in functions.php:
function pastevents($atts) { $atts = (array) $atts; $atts['format'] = '<li>#_EVENTDATES: #_EVENTLINK</li>'; return '<ul class="myeventlist">' . EM_Events::output( $atts ) . '</ul>'; } add_shortcode ( 'my_events_list', 'pastevents' );
what results in: this page
The problem: the last 2 concerts have a linebreak in the title and are displayed as code. If you click on the link, you see that the title has a linebreak and is displayed in 2 lines.
best regards
March 1, 2015 at 4:38 pm #404083Hi leRenaar!
Thank you for using Enfold.
I’m not really sure what the code above does but may you can do a str_replace to remove the BR tags: http://php.net/str_replace
Regards,
IsmaelMarch 5, 2015 at 12:48 pm #406364Hi Ismael,
very interesting php-code, new for me. I have to convert the <br/> into a +sign. The examples making that possible for me, but how do you fit this in a shortcode?
The shortcode is
function em_get_events_list_grouped_shortcode($args = array(), $format = ''){ $args = (array) $args; $args['ajax'] = isset($args['ajax']) ? $args['ajax']:(!defined('EM_AJAX') || EM_AJAX ); $args['format'] = ($format != '' || empty($args['format'])) ? $format : $args['format']; $args['format'] = html_entity_decode($args['format']); //shortcode doesn't accept html $args['limit'] = isset($args['limit']) ? $args['limit'] : get_option('dbem_events_default_limit'); if( empty($args['format']) && empty($args['format_header']) && empty($args['format_footer']) ){ ob_start(); if( !empty($args['ajax']) ){ echo '<div class="em-search-ajax">'; } //open AJAX wrapper em_locate_template('templates/events-list-grouped.php', true, array('args'=>$args)); if( !empty($args['ajax']) ) echo "</div>"; //close AJAX wrapper $return = ob_get_clean(); }else{ $args['ajax'] = false; $pno = ( !empty($args['pagination']) && !empty($_GET['pno']) && is_numeric($_GET['pno']) )? $_GET['pno'] : 1; $args['page'] = ( !empty($args['pagination']) && !empty($args['page']) && is_numeric($args['page']) )? $args['page'] : $pno; $return = EM_Events::output_grouped( $args ); } return $return; } add_shortcode ( 'events_list_grouped', 'em_get_events_list_grouped_shortcode' );
Where is the best place to use str_replace ?
best regards
March 9, 2015 at 2:05 am #407805Hey!
You can try this:
function pastevents($atts) { $atts = (array) $atts; $atts['format'] = '<li>#_EVENTDATES: #_EVENTLINK</li>'; $output = EM_Events::output( $atts ); $output = str_replace(array('<br>','<br/>'),'',$output); return '<ul class="myeventlist">' . $output . '</ul>'; } add_shortcode ( 'my_events_list', 'pastevents' );
Best regards,
IsmaelMarch 9, 2015 at 5:09 pm #408266Brilliant solution Ismael. Now i understand the workflow and connection between that var. The result was not what i hoped. Today i tried a other solution (with jQuery):
(function( $ ) { "use strict"; $( document ).ready(function() { // alert ("Hello, World"); var thePage = $(".page-id-314 .entry-content"); thePage.html(thePage.html().replace(/(<BR>)/ig, " + ")); }); }(jQuery));
thanks for the solutions and patience,
leRenaar -
AuthorPosts
- The topic ‘Eventes Manager display as html’ is closed to new replies.