Regex removal

13 posts by 2 authors in: Forums > CMS Builder
Last Post: May 14, 2010   (RSS)

By dsternalski - May 7, 2010

Hi,

I have coded the pages so that depending on what is selected in the management system depends on where the object goes.

The problem that I found with this is that articles that aren't meant to be in the navigation are displaying in the navigation (at the moment hidden by an a class).

Is there a regex that I can use that will remove the empty <li></li> tags out of the generated source code?

Please find attached the source code, navigation files and a page file.

Re: [dsternalski] Regex removal

By Jason - May 10, 2010

Hi,

So you are trying to control what is displayed in navigation.php?

Can you tell me exactly which articles that are not meant to be in the navigation are showing up? Do you want to just hide these articles, or do you want to not have them outputted at all?

Let me know and I'll see what I can do.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Regex removal

By dsternalski - May 10, 2010

Hi,

Yes I am trying to control what is being displayed in the navigation.

All <li> that aren't meant to be in the navigation at the moment are using a class of "noNav" in the <a> tag as these are features on the page but don't require any navigation to display either on the front end or in the source code, but at the moment they are displaying in the source code.

Also in the code there are empty <li></li> which need to not display in the source code (I just took out the link completely from the code rather than add the "noNav" class).

Re: [dsternalski] Regex removal

By Jason - May 10, 2010

Hi,

So, links that have the "noNav" class, you still want them to display?

As for the empty <li></li>, where exactly in the code are those being produced? For a normal <li>, what fields would be outputted there?

It is possible that they are outputted when you have records with empty fields. You could always check the field before you output it, like this:

<?php if($categoryRecord['name']): ?>
*OUTPUT <li></li>*
<?php endif?>


Let me know if this sounds like we're on the right track.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [dsternalski] Regex removal

By Jason - May 11, 2010

Hi,

From what I can see, you're outputting an <a> tags when "featureSelect" has been selected. An easy way to get rid of these tags, is to only output the <a> tags you want when "featureSelect" has not been selected.

For example, in your code you are currently displaying a link like this:

<?php if (strlen($categoryRecord['featureSelect'])) { ?>
<a class="noNav" href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
<?php } else { ?>
<a <?php ?> href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
<?php } ?>


You can replace this with this code:

<?php if(!$categoryRecord['featureSelect']) : ?>
<a <?php ?> href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
<?php endif ?>


Let's start there. Give that a try and let me know if that works out.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Regex removal

By dsternalski - May 11, 2010

Hi,

this worked! thank you!!!

Re: [dsternalski] Regex removal

By Jason - May 11, 2010

Awesome! Glad to hear that's working for you now.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Regex removal

By dsternalski - May 12, 2010

Hi,

this worked on the main navigation section of my code, but the empty <li></li> are still displaying on my other section of navigation (even though they're using the same code?).

Re: [dsternalski] Regex removal

By Jason - May 14, 2010

Hi,

Which file is the other navigation coming from? Is it curriculum.php?

Let me know and attach the most up to date copies of the files.

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/