• Resolved tomostrand

    (@tomostrand)


    I use the following code to display upcoming_events on a web page:

    [my_calendar_upcoming before=”0″ after=”4″ type=”event” fallback=”Watch this space for future announcements” template=”
    <h4>{date}
    {title}.</h4>
    <h5>{description}</h5>
    <h4>{location}</h4>
    ” order=”asc” show_today=”yes” skip=”0″ ltype=”” lvalue=””]

    This works fine, it displays the next 4 events Date,Title,Description,Location in chronological order.
    However, if I try to add formatting to the {description} line, the display completely changes, but not according to the requested format. For example, putting in
    <h5 style=”color:#FF0000″>{description}</h5>
    causes the Description and the Location to disappear from the displayed output, and somehow the start and end times of each event appear at the beginning of the display. It doesn’t seem to make any difference what I put in the style specification–any color or any other style attribute has the same effect.
    I’m using Version 3.1.13 of My Calendar.

    What’s going on??

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Joe Dolson

    (@joedolson)

    You can’t use double quotes within other double quotes; it’ll create an error.

    I suggest using the Template Editor to create your template, then reference it using the provided ID in your shortcode; that’ll give you a lot more freedom in your template.

    Thread Starter tomostrand

    (@tomostrand)

    Excellent suggestion, thank you! I just need to know the proper syntax to reference a custom template in the shortcode. Also, do I use the template name, or the keyword that’s generated by the Template Editor?

    Plugin Author Joe Dolson

    (@joedolson)

    Use the keyword; the format would simply be [my_calendar_upcoming template="keyword"]

    Thread Starter tomostrand

    (@tomostrand)

    I’m clearly doing something wrong. I created a custom template with essentially the same code in my original question, leaving out the [my_calendar_upcoming, as well as the closing ]. Then I referenced the template, but the output is nothing like what the tags are specifying. In particular, it displays 6 events, not 4, and 3 of those are from past dates. Also, the information displayed is not what the template asks for: the Location is not shown, while the display includes the start and end times, which are not in the template.

    I expected the template to work more or less like a macro, but the processor seems to be overriding the actual template code.

    Plugin Author Joe Dolson

    (@joedolson)

    The template is just the layout portion; the section contained with the ‘template’ parameter of the shortcode. All of the other settings should stay as they are.

    Thread Starter tomostrand

    (@tomostrand)

    Joe: I now have the custom template working correctly, and I also sort of discovered the reason for the earlier weird output display. There seem to be two independent problems which interact. Problem 1: Typing a space in the classic WordPress visual editor view inserts either a soft space OR an   hard space into the html text. It’s not clear to me how the editor determines which kind of space to insert (it seems to alternate inserting soft and hard spaces).
    Problem 2: If a hard space is inserted directly in front of template= “…”, the html text looks like this:  template=”…” Now  template looks like a single word, and the short code parser doesn’t process it correctly. So the specified template is ignored and the default version of the event is displayed.

    I have no idea how to deal with the WordPress editor, but perhaps you could modify either your parser or lexical analyzer to recognize   as a space, even if it’s directly adjacent to following text.
    In any case, thanks very much for your replies, which led me to a satisfactory solution to my problem.

    Thread Starter tomostrand

    (@tomostrand)

    (Ignore previous post, &nbsp; was not escaped)
    Joe: I now have the custom template working correctly, and I also sort of discovered the reason for the earlier weird output display. There seem to be two independent problems which interact. Problem 1: Typing a space in the classic WordPress visual editor view inserts either a soft space OR an &nbsp; hard space into the html text. It’s not clear to me how the editor determines which kind of space to insert (it seems to alternate inserting soft and hard spaces).
    Problem 2: If a hard space is inserted directly in front of template=, the html text looks like this: &nbsp;template= Now &nbsp;template looks like a single word, and the short code parser doesn’t process it correctly. So the specified template is ignored and the default version of the event is displayed.

    I have no idea how to deal with the WordPress editor, but perhaps you could modify either your parser or lexical analyzer to recognize   as a space, even if it’s directly adjacent to following text.
    In any case, thanks very much for your replies, which led me to a satisfactory solution to my problem.

    Plugin Author Joe Dolson

    (@joedolson)

    So, the parsing of shortcodes isn’t done by My Calendar; it’s done by WordPress core – the entire shortcode API is part of the core WordPress software. So anything related to failing to recognize a shortcode is something I can’t really do anything about in My Calendar – it’s a WordPress problem.

    Using the visual editor and incorporating shortcodes is, generally speaking, a mess…

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Adding format to template tag produces weird results in the displayed output’ is closed to new replies.