e107inc / bootstrap4

Bootstrap4 Theme folder working repo
1 stars 0 forks source link

breadcrumbs outside tablerender as theme shortcodes #1

Closed Jimmi08 closed 5 years ago

Jimmi08 commented 5 years ago

Example from old theme (not sure if this still works)

  /* {THEMEBREADCRUMBS}
  /* level :  1  home + page stop */    
    function sc_theme_breadcrumbs($parm='')
    {
   $breadcrumb = array();

   if(e_PAGE == "page.php") {
       $sc   = e107::getScBatch('page', null, 'cpage');
       $data = $sc->getVars();
       if(!(empty($data['book_sef'])))  { 
         $breadcrumb[] = array('text'=> $data['book_name'], 'url'=> e107::getUrl()->create('page/book/index', $data,'allow=chapter_id,chapter_sef,book_sef,page_sef'));
       }
       if(!(empty($data['chapter_sef'])))  { 
         $breadcrumb[] = array('text'=> $data['chapter_name'], 'url'=> e107::getUrl()->create('page/chapter/index', $data,'allow=chapter_id,chapter_sef,book_sef'));
       } 
       $breadcrumb[] = array('text'=> $this->sc_theme_pagetitle());      
   }
   elseif((e_PAGE == "index.php") && (strpos(e_REQUEST_URI, 'gallery') !== false)  ) {     
       $sc   = e107::getScBatch('gallery');
       $data = $sc->getVars();
       $breadcrumb[] = array('text' => LAN_PLUGIN_GALLERY_TITLE, 'url' => e107::getUrl()->create('gallery'));
       if(vartrue($data['media_id']))
             {
                $breadcrumb[] = array('text' => $data['media_cat_title'], 'url' => e107::getUrl()->create('gallery/index/list', $data));
             }  
   }
   else {

    $breadcrumb = array();
    $breadcrumb[] = array('text'=> $this->sc_theme_pagetitle()); 
   }
   return $this->breadcrumb($breadcrumb);
  }  
    /**
     * Render a Breadcrumb in Bootstrap format. 
     * @param $array
     * @param $array[url]
     * @param $array[text]
     */

    function breadcrumb($array)
    {
        if(!is_array($array)){ return; }

        $opt = array();

        $homeIcon = '<em class="fa fa-home"></em>';

        $opt[] = "<a href='".e_HTTP."'>".$homeIcon." Home </a>"; // Add Site-Pref to disable?

        $text = '<div class="breadcrumb-box">';
    $text .= '<div class="breadcrumb-light">';
    $i = 1;
        foreach($array as $val)
        {
            $ret = "<span itemprop='breadcrumb' itemscope='' itemtype='https://schema.org/breadcrumb'>
                                    <span itemscope='' itemtype='http://schema.org/BreadcrumbList'>
                                        <span itemprop='itemListElement' itemscope='' itemtype='http://schema.org/ListItem'>";
      //<a href="#" class="pagetitle" itemprop="item">              
            $ret .= vartrue($val['url']) ? "<a href='".$val['url']."' class='pagetitle' itemprop='item'>" : "";         
            $name = vartrue($val['text'],'');
      $ret .= "<span itemprop='name'>{$name}</span>";
            $ret .= vartrue($val['url']) ? "</a>" : "";
      $ret .= "<meta itemprop='position' content='{$i}'>";
      $ret .= "</span>";
      $ret .= "</span>";
      $ret .= "</span>";            
            if($ret != '')
            {
                $opt[] = $ret;
            }   
        }

        $sep = '<span class="separator">/</span>';

        $text .= implode($sep."</span><span itemprop='breadcrumb'",$opt); 

        $text .= "</div></div>";

    //  return print_a($opt,true);

        return $text;   

    }
  /* {THEME_PAGETITLE} */ 
  function sc_theme_pagetitle($parm='')
        {   
       if((strpos(e_REQUEST_URI, 'login') !== false)) {return LAN_TO_LOGINPAGENAME;}
       if((strpos(e_REQUEST_URI, 'download') !== false)) {return LAN_PLUGIN_DOWNLOAD_NAME;}

       if(defined('e_PAGETITLE') )  { return e_PAGETITLE; }

      // fix for news.php without e_QUERY
       if(!defined('e_PAGETITLE') && defined('PAGE_NAME'))
                {
                    define('e_PAGETITLE', PAGE_NAME);
                    e107::meta('og:title', PAGE_NAME);
                     return e_PAGETITLE; 
                }                     
      // fix for user.php
      if(e_PAGE == "user.php") {
        if(e_QUERY != '')  { return LAN_USER_50 ;  }
              else { return LAN_USER_52 ; }
      }
     }  
CaMer0n commented 5 years ago

@Jimmi08 The 'title' part of this should be solved by the "Magic Shortcodes" - which grab information from the tablerender() passes.

Jimmi08 commented 5 years ago

@CaMer0n Tested, it works.

CaMer0n commented 5 years ago

Closing this. Working well on this end.