XPHP Logic for Existence of a directory

Hello,

Is there an XPHP way of checking to see if a certain directory exists on the server to include a certain HTML code.

For example:

     <div class="rvt-row rvt-m-top-xl">
      <a href="%%xphp_group_directory%%media/" class="rvt-cta rvt-cta--button">Explore media resources </a>
     </div>

Can we do an IF before we display:

<a href="%%xphp_group_directory%%media/" class="rvt-cta rvt-cta--button">Explore media resources </a>

The IF would basically check to see if %%xphp_group_directory%%media/ exists on the server before adding the code.

Any insight will be helpful.

Akbar

Hey Akbar – there’s not currently any XPHP functions that check the filesystem like you’re describing. It is something a custom module could do relatively easily, though—any variables that you save to the globals array like $GLOBALS['foobar'] early enough in a custom module (say, in onLoad, or I think onBeforeOutput would work too) will be exposed to the page as XPHP variables (<xphp var="foobar"/>.

<xphp content="true">
   <if var="server_path" value="{group_directory}index.php"/>
     <content>
        <!– show this if it's the group homepage –>
     </content>
</xphp>

Is that not something that could be used right in the template instead of going to the trouble of creating Custom module? I found that on your documentation site.

Thanks,

Akbar

Or, something like this:

<xphp if="server_path" matches="{group_directory}index.php">HTML CODE here</xphp>

The server_path variable contains the path of the currently loaded page – XPHP Variables - LiveWhale Support – so it wouldn’t be able to check for the existence of another page like I think you’re envisioning.

<xphp if="server_path" matches="{group_directory}index.php"> translates to “If this is the group homepage”

or you could think of it as
<xphp if="server_path" matches="/foo/bar/index.php">This is the /foo/bar/ page</xphp>