Announcement

Collapse
No announcement yet.

List from just one section level...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Originally posted by Zest View Post
    Brill, this work great! Just typed in wrong. Just one last thing to finish this off?

    How can I now add a menu header e.g.
    <h2><actinic:variable name="SectionName" /></h2>
    But this stay static for the level 1 header? It would also be good to identify this so you have some code that could also fetch the brand logo?

    Hope you can help
    <actinic:variable name="SectionName" /> is the Section Name of the current section so it would change as you move through the levels of the navigation. the code given earlier already gets the Section Text which is the database field that holds the section name, so all you have to do is modify the code in GetLevel1Section() to return both the ID and the name and then split the returned code into two variables that you can use instead of just one. You can return the two items in the resultage string by separating them with "|", take a look in Gabes code to see how he was doing it and then splitting out the items.

    Malcolm

    SellerDeck Accredited Partner,
    SellerDeck 2016 Extensions, and
    Custom Packages

    Comment


      #17
      Tried to figure this out but struggling, sorry to be a pain!!! but how do I achieve the above?

      Comment


        #18
        Originally posted by Zest View Post
        Brill, this work great! Just typed in wrong. Just one last thing to finish this off?

        How can I now add a menu header e.g.
        <h2><actinic:variable name="SectionName" /></h2>
        But this stay static for the level 1 header? It would also be good to identify this so you have some code that could also fetch the brand logo?

        Hope you can help
        Try this

        Code:
        if (!function_exists('GetLevel1Section')) {
            function GetLevel1Section($connect,$sectref)
            {
        
                $query = "SELECT [Section Text], [nParentSectionID], [nSectionID] FROM [Catalog Section] WHERE [nSectionID] LIKE '".$sectref."'";
                $result = odbc_exec($connect, $query);
                $returnstring="";
                while(odbc_fetch_row($result)){
                
                    $SectionText =  odbc_result($result, 1);
                    $nParentSectionID = odbc_result($result, 2);
                    $nSectionID = odbc_result($result, 3);
                    
                    if ($nParentSectionID!=0) {
                       $returnstring=GetLevel1Section($connect,$nParentSectionID);
                    } else {
                       $returnstring=$nSectionID."|".$SectionText;
                    }
                }
                odbc_free_result($result);
                //odbc_close($connect);
                return $returnstring;
            }
        }
        
        if (!function_exists('GetLevel1SectionWrapper')) {
            function GetLevel1SectionWrapper($sectid,myresult) {
                $connect = odbc_pconnect("ActinicCatalog9","","", SQL_CUR_USE_ODBC);
                $resultage = GetLevel1Section($connect,$sectid);
                $resultarray = explode("|", $resultage);
                odbc_close_all();    
                return $resultarray[myresult];
            }
        }
        Now when you call GetLevel1SectionWrapper pass it a value (0 or 1) to select the return value of SectionID or SectionName.

        To get top level section ID
        Code:
         <actinic:block php="true" > MakeNav(GetLevel1SectionWrapper('<actinic:variable name="SectionID" selectable="false" />',0),2,0,<actinic:variable name="SectionID" selectable="false" />); </actinic:block>
        To get top level section name
        Code:
         <actinic:block php="true" > echo GetLevel1SectionWrapper('<actinic:variable name="SectionID" selectable="false" />',1); </actinic:block>
        Last edited by malbro; 09-Sep-2011, 05:24 PM. Reason: correcting mistake in code

        Malcolm

        SellerDeck Accredited Partner,
        SellerDeck 2016 Extensions, and
        Custom Packages

        Comment


          #19
          Great, Thanks but above code returns error:

          Parse error, expecting `''' or `T VARIABLE' in main on line 39

          if (!function_exists('GetLevel1SectionWrapper')) {
          function GetLevel1SectionWrapper($sectid,myresult) {

          Comment


            #20
            Originally posted by Zest View Post
            Great, Thanks but above code returns error:

            Parse error, expecting `''' or `T VARIABLE' in main on line 39

            if (!function_exists('GetLevel1SectionWrapper')) {
            function GetLevel1SectionWrapper($sectid,myresult) {
            Oops Mixing my programming languages the line should be
            Code:
            $returnstring=$nSectionID."|".$SectionText;
            and not
            Code:
            $returnstring=$nSectionID + "|" + $SectionText;
            I have corrected the original post

            Malcolm

            SellerDeck Accredited Partner,
            SellerDeck 2016 Extensions, and
            Custom Packages

            Comment

            Working...
            X