Static page dropdown within static page in OctoberCMS

后端 未结 3 1108
青春惊慌失措
青春惊慌失措 2021-01-24 03:18

I have a template with a slideshow in it. Each slide consists of:

  • Image
  • Caption
  • A paragraph of text
  • Button

For the first

3条回答
  •  無奈伤痛
    2021-01-24 03:39

    I have the same Problem like Panagiotis Koursaris. I used the template variables without a repeater. I fixed the problem by specifying the options and adding an alias in Plugin boot method. e.g.:

    {variable name="type" type="dropdown" options="StaticPage | getTypeOptions" label="Link Type" tab="Text Image Header (dark)"}{/variable}
    
    \Illuminate\Foundation\AliasLoader::getInstance()->alias('StaticPage','RainLab\\Pages\\Classes\\Page');
    

    But the trigger don't work, all dropdowns were displayed. Any idea to fix it?

    The next problem is, that all cms pages are displayed as follows:

    projects [projects]

    I change the code in the second loop as follows:

    if ($type == 'cms-page') {
                $cmsPages = [];
    
                if (!is_array($value)) {
                  continue;
                }
    
                foreach ($value as $url => $pageArray) {
                  $page = \Cms\Classes\Page::find($url);
                  if ($page) {
                    $baseName = $page->getBaseFileName();
                    $pos = strrpos($baseName, '/');
    
                    $dir = $pos !== false ? substr($baseName, 0, $pos) . ' / ' : null;
                    $cmsPages[$baseName] = strlen($page->title) ? $dir . $page->title : $baseName;
                  }
                }
    
                $value = $cmsPages;
              }
    

提交回复
热议问题