Support » Plugin: EZ SHORTCURL Shortcodes to Fetch and Parse External Content » Text / HTML strings and length?

  • Resolved ClaireF


    Hi Eli –

    I’m trying to select some content using the start/stop and the length variable. For example:

    <p>As with other seafood, shrimp is high in <a href="/wiki/Calcium" title="Calcium">calcium</a>, <a href="/wiki/Iodine" title="Iodine">iodine</a> and <a href="/wiki/Protein" title="Protein">protein</a> but low in <a href="/wiki/Food_energy" title="Food energy">food energy</a>. A shrimp-based meal is also a significant source of <a href="/wiki/Cholesterol" title="Cholesterol">cholesterol</a>, from 122 <a href="/wiki/Milligram" title="Milligram">mg</a> to 251 mg per 100 <a href="/wiki/Gram" title="Gram">g</a> of shrimp, depending on the method of preparation.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span>[</span>3<span>]</span></a></sup> Shrimp consumption, however, is considered healthy for the circulatory system because the lack of significant levels of saturated fat in shrimp means that the high cholesterol content in shrimp actually improves the ratio of LDL to HDL cholesterol and lowers <a href="/wiki/Triglycerides" title="Triglycerides">triglycerides</a>.<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span>[</span>4<span>]</span></a></sup></p>
    <p>Shrimp and other <a href="/wiki/Shellfish" title="Shellfish">shellfish</a> are among the most common <a href="/wiki/Food_allergy" title="Food allergy">food allergens</a>.<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span>[</span>5<span>]</span></a></sup> They are not <a href="/wiki/Kosher" title="Kosher">kosher</a> and thus are forbidden in <a href="/wiki/Jewish_cuisine" title="Jewish cuisine">Jewish cuisine</a>. Shrimp are <a href="/wiki/Halal" title="Halal">halal</a> according to some <a href="/wiki/Madh%C4%81hib" title="Madhāhib">madhāhib</a>, and therefore <a href="/wiki/Comparison_of_Islamic_and_Jewish_dietary_laws#Similarities" title="Comparison of Islamic and Jewish dietary laws">permissible to most</a>, but not all, <a href="/wiki/Muslim" title="Muslim">Muslims</a>.</p>
    <div style="clear:both;"></div>
    <strong class="error mw-ext-cite-error">Cite error: There are <code><ref></code> tags on this page, but the references will not show without a <code>{{reflist}}</code> template (see the <a href="Cite_errors/Cite_error_refs_without_references" title="Help:Cite errors/Cite error refs without references">help page</a>).</p>

    If I use start='<p>As with ‘ stop=’ms. ‘ length=”-8″ I would hope to end up with text as follows:

    As with other seafood, shrimp…. …..permissible to most, but not all, <a href="/wiki/Muslim" title="Muslim">Muslims.

    But while the start -8 is perfect, the stop doesn’t stop after the given stop data and continues to the end of the entire chosen selection – it’s as though the stop isn’t being seen.

    The error message seems to imply the same: SHORTCURL stop=ms</a>. but not found in (§ion=13)!

    but when I open the array, the string is clearly there…

    Would appreciate any suggestions you might have thx.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Eli


    The last part you are trying to match has the “Closing Anchor” tag between the word “Muslims” and the “.” so “ms.” is not found.

    Try using stop=’Muslims’ with no length parameter and then adjust your length accordingly.

    Thx – sorry I had copied that last part wrong.

    Using stop=’Muslims’ and removing the length variable does show the text truncated before the M.

    Also, using stop=’Muslims.’ stops the text correctly before the M.

    However, putting various lengths in doesn’t bring back the word – it stays truncated.

    stop=’Muslims.’ length=”-12″
    Shrimp and other shellfish are among the most common food allergens.[5] They are not kosher and thus are forbidden in Jewish cuisine. Shrimp are halal according to some madhāhib, and therefore permissible to most, but not all,

    stop=’Muslims.’ length=”-5″
    shows the same
    stop=’Muslims’ length=”-5″
    shows the same
    stop=’Muslims’ length=”-1″
    shows the same
    stop=’Muslims’ with length parameter removed shows the same

    I’ve cleared out the browser cache as well to see if that makes a difference but it did not.

    sorry about part of the above – i’m not using the backticks correctly so the posts are being stripped of </a>

    Plugin Author Eli


    I know you said you are stripping the tags but I think you are doing that after the remote_get is performed so the shortcode parameters take the tags into account. Therefor, small changes to the length parameter are not noticed because it is just changing how much of the Anchor tag gets truncated before the word “Muslims”.

    If you are wanting to end after the word “Muslims” then try using the “end” parameter in place of “stop”.

    Like this:
    [remote_get url="" start='As with' end='Muslims']

    Note: If you use tags like ‘<p>’ in the shortcode then try using the encoded form ‘<p>’ (without spaces). WordPress tends to modify the content by adding CrLf around tags, which breaks the shordode.

    just to be clear, the tags are in the string but are not showing up on this forum. they are in the field in WP, but may be problematic.

    in any case, end works perfectly and lets me select the html to end with as well – e.g. ‘Muslims</a>.’ For my purposes this is much better as it gives really direct control over the string management. Please add to FAQ 🙂

    one more thing – can you explain how the length function is meant to work? is it the elements in quotes, then stepped to the left by the number in the quotes? also, is there such thing as a length “+” element? this would be great as it would let the string take into consideration any html code without identifying it – this has been problematic in other cases concerning tr and td and table strings, which the plugin didn’t like very much. Using end does provides workaround for this but I can see some batch-like uses where using + or – would be helpful as well.


    Plugin Author Eli


    The “length” is passed as the third parameter to the PHP function substr, so you can use “-” (negative) to omit characters from the end of string, but I don’t think “+” will work.

    Yet another alternative would be to switch back to using “stop” but have it look for the next “div” instead of the last word, like this:

    stop='<div style=”clear:both;”<‘

    remember to use the encoded tags (“& lt ;” without spaces) this did not come out right on the forum in my last post.

    Plugin Author Eli


    stop='<div style="clear:both;">'

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Text / HTML strings and length?’ is closed to new replies.