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: [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: [Jason] Regex removal

By dsternalski - May 10, 2010

Hi,

The links with "noNav" don't need to be displayed.

The <li></li> are being used for the Navigation Name field for the navigation. However, these fields are also being used when the features are being created (so the user knows what article holds a feature).

As for the empty <li></li> tags, these are the same as the "noNav" only I removed the <a> tag from the code, so neither of these need to display.

All Category name fields are being used.

Please note that "noNav" and the empty <li></li> tags are navigation that isn't needed as these are the features for the page.

Please find attached 3 screen shots. The elements in the red box is one of the features that either displays in the source with "noNav" or displays as empty an <li></li>.

I hope this makes sense.
Attachments:

frontend.jpg 741K

backendlist.jpg 288K

articleinfo.jpg 357K

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/