snipt

Ctrl+h for KB shortcuts

Text only

Getting the path to a PODS Image/File Field and Displaying it if it's not empty

1
2
3
4
5
6
7
<?php
$map_pdf_url = $obj->field( 'map_pdf.guid', true );

if ( 0 < strlen( $map_pdf_url ) ) {
echo '<a href="' . $map_pdf_url . '">Download PDF</a>';
};
?>
https://snipt.net/embed/506a0b70cfbd87afa6ebc68b78d8040d/
/raw/506a0b70cfbd87afa6ebc68b78d8040d/
506a0b70cfbd87afa6ebc68b78d8040d
text
Text only
7
2019-08-21T18:59:03
True
False
False
/api/public/snipt/60329/
getting-the-path-to-a-pods-imagefile-field-and-displaying-it-if-its-not-empty
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>&lt;?php </span><span id="L-2"><a name="L-2"></a>$map_pdf_url = $obj-&gt;field( &#39;map_pdf.guid&#39;, true ); </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a>if ( 0 &lt; strlen( $map_pdf_url ) ) { </span><span id="L-5"><a name="L-5"></a>echo &#39;&lt;a href=&quot;&#39; . $map_pdf_url . &#39;&quot;&gt;Download PDF&lt;/a&gt;&#39;; </span><span id="L-6"><a name="L-6"></a>}; </span><span id="L-7"><a name="L-7"></a>?&gt; </span></pre></div> </td></tr></table>
conditional, guid, if, image, php, pods, template