• Resolved ernstwg

    (@ernstwg)


    Hi David.

    Within a mla_markup shortcode I included a link like this [+iptc:2#025,single+]>[+iptc:2#025,single+]

    Scenario iptc:2#025 has a keyword phrase with word1 and word2. The link above takes only word1 into consideration: …/anzeigebildernachparameter/?sk=word1. Filling the space with %20 manually looks not nice and is not reliable.

    Any idea how to make something on the possible which looks like: …/anzeigebildernachparameter/?sk=word1%20word2
    ?

    Thank you. Ernst Wilhelm

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter ernstwg

    (@ernstwg)

    Sorry.

    a href=…/anzeigebildernachparameter/?sk=[+iptc:2#025,single+]>[+iptc:2#025,single+] /a

    • This reply was modified 2 years, 2 months ago by ernstwg.
    Plugin Author David Lingren

    (@dglingren)

    Good to hear from you, and thanks for an interesting question.

    As you discovered, the ,single format/option code precludes you from adding another formatting operation such as substring replacement. However, since the IPTC Keywords value is an array you can use an alternate notation to solve your problem.

    You wrote “Filling the space with %20 manually…” You could use this notation instead:

    [+iptc:2#025.0,str_replace(' ','%20')+]

    The .0 array notation selects the first array element, just as the ,single format/option code would do. That allows you to add the ,str_replace(s,r) format/option code to do the replacement. That is not the best solution, though. A better (and simpler) alternative is:

    [+iptc:2#025.0,url+]

    The ,url format/option code will ensure that all special characters are converted to a URL-safe equivalent. For example, spaces are replaced by the plus character (+) as the URL standard specifies.

    I hope that solves your problem. I am marking this topic resolved, but please update it if you have problems or further questions regarding the solution outlined above. Thanks for your long-standing interest in the plugin.

    Thread Starter ernstwg

    (@ernstwg)

    David many thanks, much appreciated.

    Thread Starter ernstwg

    (@ernstwg)

    David. There is something popping up. If there is an image with 2 Keywords it works great with [+iptc:2#025.0,url+] and [+iptc:2#025.1,url+]. If there is only one keyword it doesnot work with the array notation [+iptc:2#025.0,url+] as I expect. I must use [+iptc:2#025,url+].

    I am excited ??

    • This reply was modified 2 years, 2 months ago by ernstwg.
    • This reply was modified 2 years, 2 months ago by ernstwg.
    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the two different cases. You can use a content template to handle both cases automatically:

    {+template:({+iptc:2#025.0,url+}|{+iptc:2#025,url+})+}

    Multiple keywords are handled by the first alternative and the single keyword case is handled by the second. You could add a third alternative to handle the case of no keywords if that makes sense for your application. Let me know if you still have problems with that solution.

    Thread Starter ernstwg

    (@ernstwg)

    David. It sounds interesting and logical.

    But I have no clue how to use it. My code for the mla_markup is

    <td class='gallery-icon' width="70%">
        [+link+]<p>[+iptc:2#116+]</p>
    </td>
    
    <td class='wp-caption-text gallery-caption'>
    
    <h1>[+iptc:2#005+]</h1>
    <p style="font-size:80%"><a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#020.1,url+]>[+iptc:2#020.1+]</a> >> <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#020.0,url+]>[+iptc:2#020.0+]</a>  >> <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#005,url+]>[+iptc:2#005+]</a></p>
    <br>
    [+iptc:2#120+] | [+iptc:2#040+]
    <br />
    [+iptc:2#055,date('F Y')+]
    <br />
    <br />
    
    <p><strong>Rechte</strong> [+iptc:2#116+] <a rel="nofollow" href=/lizenzbedingungen/?sk=[+iptc:2#116,url+]>Lizenzbedingungen</a> <a rel="nofollow" href=/lizenzbedingungen/?sk=[+iptc:2#116,url+]>Anfrage</a></p>
    
    <strong>Stichw?rter</strong> 
    <br>Index ? <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#025,url+]>[+iptc:2#025+]</a>  
    <br>Index 0 <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#025.0,url+]>[+iptc:2#025.0]</a>  
    <br>Index 1 <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#025.1,url+]>[+iptc:2#025.1+]</a> 
    <br>Index 2 <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#025.2,url+]>[+iptc:2#025.2+]</a> 
    <br>Index 3 <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#025.3,url+]>[+iptc:2#025.3+]</a> 
    <br>Index 4 <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#025.4,url+]>[+iptc:2#025.4+]</a> 
    <br>
    
    <strong>Systematik</strong> 
    <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#005,url+]>[+iptc:2#005+]</a> 
    <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#020.1,url+]>[+iptc:2#020.1+]</a> 
    <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#020.0,url+]>[+iptc:2#020.0+]</a> 
    <br>
    
    <strong>Habitat, Ortsangaben</strong> 
    <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#092,url+]>[+iptc:2#092+]</a> 
    <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#090,url+]>[+iptc:2#090+]</a> 
    <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#095,url+]>[+iptc:2#095+]</a> 
    <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#101,url+]>[+iptc:2#101+]</a></p>
    
    <p><strong>Beitrag</strong> <a href=[+parent_permalink+]>[+parent_title+]</a></p>
    
    <p><strong>Externe Links [+iptc:2#005+]</strong> 
    <a href=https://www.brodowski-fotografie.de/beobachtungen/[+slug+].html>brodowski-fotografie</a> 
    <a href=https://www.nabu.de/tiere-und-pflanzen/voegel/portraets/[+slug+]>Nabu</a> 
    <a href=https://www.lbv.de/ratgeber/naturwissen/artenportraits/detail/[+slug+]>LBV</a> 
    <a href=https://de.wikipedia.org/wiki/[+slug+]>Wikipedia</a></p>

    Here’s an example https://ernst-wilhelm-grueter.info/kontexteinzelbild/?art=maeusebussard-2&bld=1794

    • This reply was modified 2 years, 2 months ago by ernstwg.
    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the full source text of your template; very helpful.

    Here is an updated “Stichw?rter” section that includes my suggestion and other improvements:

    <strong>Stichw?rter</strong> 
    <br>Index ? <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#025,url+]>[+iptc:2#025+]</a>  
    [+template:(<br>Index 0 <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+template:([+iptc:2#025.0,url+]|[+iptc:2#025,url+])+]>[+template:[+iptc:2#025.0+]|[+iptc:2#025+]|no keywords+]</a>)+]
    [+template:(<br>Index 1 <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#025.1,url+]>[+iptc:2#025.1+]</a>)+] 
    [+template:(<br>Index 2 <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#025.2,url+]>[+iptc:2#025.2+]</a>)+]
    [+template:(<br>Index 3 <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#025.3,url+]>[+iptc:2#025.3+]</a>)+]
    [+template:(<br>Index 4 <a rel="nofollow" href=/anzeigebildernachparameter/?sk=[+iptc:2#025.4,url+]>[+iptc:2#025.4+]</a>)+]
    <br>
    

    This alternative handles the cases of zero, one or more keywords. It also suppresses the empty links for keywords that do not exist. Let me know if you have problems or further questions regarding the suggested solution.

    Thread Starter ernstwg

    (@ernstwg)

    i am grateful to you.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Substring replacement for item-level substitution parameter’ is closed to new replies.