GithubHelp home page GithubHelp logo

Comments (7)

upsonp avatar upsonp commented on August 20, 2024

Thanks @michael-milette I tested your solution out last night on my home server and incorporated it into the PHP variant this morning insuring the proper theme prefix (gcwu, wet, base) was used for the H4 class tag inside the loop.

from wet-boew-php.

michael-milette avatar michael-milette commented on August 20, 2024

Thank you @upsonp for the quick response. I really appreciate it. Have a great day!

from wet-boew-php.

michael-milette avatar michael-milette commented on August 20, 2024

Hi @upsonp,

I noticed that what you implemented wasn't exactly what I proposed. The problem is the following two lines:

    $_LINK_ = $_SITE['wb_ft'.$i.'_href_'.$_PAGE['lang1']];
    if (isset($_LINK_ ) && strlen($_LINK_) > 0) {
  1. The $LINK =... line will cause a warning similar to the following if the variable $_SITE['wb_ft'.$i.'href'.$_PAGE['lang1']] doesn't exist (i.e. is unset): "Notice: Undefined index: wb_ft4_href_eng in /dist-php/theme-gcwu-fegc/cont/foot-nav.php on line 15"
  2. isset($LINK) will never be unset because the line right above it sets it. It is the $_SITE['wb_ft'.$i.'href'.$_PAGE['lang1']] variable that you want to check not the $LINK variable.

If you really want to use the $LINK variable, consider doing this instead:

    $_LINK_ = (!isset($_SITE['wb_ft'.$i.'_href_'.$_PAGE['lang1']]) ? null : $_SITE['wb_ft'.$i.'_href_'.$_PAGE['lang1']]);
    if (strlen($_LINK_) > 0) {

Here is the revised code block:

    //add the four required footer menus
    for( $i=1; isset($_SITE['wb_ft'.$i.'_text_'.$_PAGE['lang1']]); $i++ ) {
        $_TEXT_ = $_SITE['wb_ft'.$i.'_text_'.$_PAGE['lang1']];
        $_LINK_ = (!isset($_SITE['wb_ft'.$i.'_href_'.$_PAGE['lang1']]) ? null : $_SITE['wb_ft'.$i.'_href_'.$_PAGE['lang1']]);
        if (strlen($_LINK_) > 0) {
            // Add link to text only if available
            $_TEXT_ = '<a'.$_TARGET_.' href="'.$_SITE['wb_ft'.$i.'_href_'.$_PAGE['lang1']].'">'.$_TEXT_.'</a>';
        }
        echo '<section><div class="span-2"><h4 class="gcwu-col-head">'.$_TEXT_.'</h4>'.PHP_EOL;

        $_MENU_ = $_SITE['wb_ft'.$i.'_menu_file_'.$_PAGE['lang1']];
        if( file_exists($_MENU_) ) {
            include $_MENU_;
        }
        echo '</div></section>'.PHP_EOL;
    }

If you prefer, the following code produces the same results and might be a little clearer for you:

    //add the four required footer menus
    for( $i=1; isset($_SITE['wb_ft'.$i.'_text_'.$_PAGE['lang1']]); $i++ ) {
        $_TEXT_ = $_SITE['wb_ft'.$i.'_text_'.$_PAGE['lang1']];
        if (isset($_SITE['wb_ft'.$i.'_href_'.$_PAGE['lang1']])) {
            $_LINK_ = $_SITE['wb_ft'.$i.'_href_'.$_PAGE['lang1']];
        } else {
            $_LINK_ = null;
        }
        if (strlen($_LINK_) > 0) {
            // Add link to text only if available
            $_TEXT_ = '<a'.$_TARGET_.' href="'.$_SITE['wb_ft'.$i.'_href_'.$_PAGE['lang1']].'">'.$_TEXT_.'</a>';
        }
        echo '<section><div class="span-2"><h4 class="gcwu-col-head">'.$_TEXT_.'</h4>'.PHP_EOL;

        $_MENU_ = $_SITE['wb_ft'.$i.'_menu_file_'.$_PAGE['lang1']];
        if( file_exists($_MENU_) ) {
            include $_MENU_;
        }
        echo '</div></section>'.PHP_EOL;
    }

In this code block, we check to see if the $_SITE['wb_ft'.$i.'href'.$_PAGE['lang1']] variable exists (is set). If it does, assign its value to $LINK even if it is just empty. If it doesn't exist, set the $LINK variable to null.

Next, we check the link to see if there is anything in the $LINK variable. If there is, assume it is a link and turn the text into linked text.

Let me know if you have any questions or if you would like me to test the downloadable ZIP file again.

Best regards,

Michael

from wet-boew-php.

michael-milette avatar michael-milette commented on August 20, 2024

Hi @upsonp,

Just wondering if you can get this last fix into the ZIP file.

Best regards,

Michael

from wet-boew-php.

upsonp avatar upsonp commented on August 20, 2024

Thanks again @michael-milette,

I tried something a little different, I hope it works the same.

//add the four required footer menus
    for( $i=1; isset($_SITE['wb_ft'.$i.'_text_'.$_PAGE['lang1']]); $i++ ) {
        $_TEXT_ = $_SITE['wb_ft'.$i.'_text_'.$_PAGE['lang1']];
        $_LINK_ = null;
        if (isset($_SITE['wb_ft'.$i.'_href_'.$_PAGE['lang1']])) {
            $_LINK_ = $_SITE['wb_ft'.$i.'_href_'.$_PAGE['lang1']];
        }
        if (strlen($_LINK_) > 0) {
            // Add link to text only if available
            $_TEXT_ = '<a'.$_TARGET_.' href="'.$_SITE['wb_ft'.$i.'_href_'.$_PAGE['lang1']].'">'.$_TEXT_.'</a>';
        }
        echo '<section><div class="span-2"><h4 class="gcwu-col-head">'.$_TEXT_.'</h4>'.PHP_EOL;

        $_MENU_ = $_SITE['wb_ft'.$i.'_menu_file_'.$_PAGE['lang1']];
        if( file_exists($_MENU_) ) {
            include $_MENU_;
        }
        echo '</div></section>'.PHP_EOL;
    }

from wet-boew-php.

michael-milette avatar michael-milette commented on August 20, 2024

Hi @upsonp,

In one of the files, dist-php\theme-gcwu-intranet\cont\foot-nav.php, you forgot to remove one of the IF statements:

    if (isset($_LINK_ ) && strlen($_LINK_) > 0) {

Here is the code the way it is:

        if (strlen($_LINK_) > 0) {
        if (isset($_LINK_ ) && strlen($_LINK_) > 0) {
            // Add link to text only if available
            $_TEXT_ = '<a'.$_TARGET_.' href="'.$_LINK_ .'">'.$_TEXT_.'</a>';
        }

This is what it is supposed to be:

        if (strlen($_LINK_) > 0) {
           // Add link to text only if available
            $_TEXT_ = '<a'.$_TARGET_.' href="'.$_LINK_ .'">'.$_TEXT_.'</a>';
        }

The ones for the other themes all work perfectly.

Let me know if you have any questions.

Best regards,

Michael

from wet-boew-php.

upsonp avatar upsonp commented on August 20, 2024

Thanks @michael-milette I've made the correction

from wet-boew-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.