当前位置: 首页>>代码示例>>PHP>>正文


PHP Page::content方法代码示例

本文整理汇总了PHP中Grav\Common\Page\Page::content方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::content方法的具体用法?PHP Page::content怎么用?PHP Page::content使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Grav\Common\Page\Page的用法示例。


在下文中一共展示了Page::content方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: injectTemplate

 protected function injectTemplate(Page $page)
 {
     /** @var $twig \Grav\Common\Twig\Twig */
     $twig = $this->grav['twig'];
     $original_content = $page->content();
     $template = 'partials/recaptcha_container.html.twig';
     $data = ['recaptchacontact' => $this->grav['config']->get('plugins.recaptchacontact'), 'page' => $page];
     $data['recaptchacontact']['message'] = $this->submissionMessage;
     // The surrounding div tags are SOLELY a workaround for a
     // Parsedown bug that throws away anything after the page content
     // which, in this case is the entire form, if it is not surrounded.
     $page->content('<div>' . $original_content . $twig->processTemplate($template, $data) . '</div>');
 }
开发者ID:martinec,项目名称:recaptchacontact,代码行数:13,代码来源:recaptchacontact.php

示例2: processPage

 /**
  * Twig process that renders a page item. It supports two variations:
  * 1) Handles modular pages by rendering a specific page based on its modular twig template
  * 2) Renders individual page items for twig processing before the site rendering
  *
  * @param  Page   $item    The page item to render
  * @param  string $content Optional content override
  * @return string          The rendered output
  * @throws \Twig_Error_Loader
  */
 public function processPage(Page $item, $content = null)
 {
     $content = $content !== null ? $content : $item->content();
     // override the twig header vars for local resolution
     $this->grav->fireEvent('onTwigPageVariables');
     $twig_vars = $this->twig_vars;
     $twig_vars['page'] = $item;
     $twig_vars['media'] = $item->media();
     $twig_vars['header'] = $item->header();
     $local_twig = clone $this->twig;
     $modular_twig = $item->modularTwig();
     $process_twig = isset($item->header()->process['twig']) ? $item->header()->process['twig'] : false;
     try {
         // Process Modular Twig
         if ($modular_twig) {
             $twig_vars['content'] = $content;
             $template = $item->template() . TEMPLATE_EXT;
             $output = $content = $local_twig->render($template, $twig_vars);
         }
         // Process in-page Twig
         if (!$modular_twig || $modular_twig && $process_twig) {
             $name = '@Page:' . $item->path();
             $this->setTemplate($name, $content);
             $output = $local_twig->render($name, $twig_vars);
         }
     } catch (\Twig_Error_Loader $e) {
         throw new \RuntimeException($e->getRawMessage(), 404, $e);
     }
     return $output;
 }
开发者ID:sunilkgrao,项目名称:grav-test,代码行数:40,代码来源:Twig.php

示例3: onAdminPagesInitialized

 /**
  * Replaces page object with admin one.
  */
 public function onAdminPagesInitialized()
 {
     // Create admin page.
     $page = new Page();
     $page->init(new \SplFileInfo(__DIR__ . "/pages/gantry.md"));
     $page->slug('gantry');
     // Dispatch Gantry in output buffer.
     ob_start();
     $gantry = Gantry::instance();
     $gantry['router']->dispatch();
     $content = ob_get_clean();
     // Store response into the page.
     $page->content($content);
     // Hook page into Grav as current page.
     unset($this->grav['page']);
     $this->grav['page'] = function () use($page) {
         return $page;
     };
 }
开发者ID:sam-suresh,项目名称:gantry5,代码行数:22,代码来源:gantry5.php

示例4: processPage

 /**
  * @param Page $page
  * @param Data $config
  * @return string
  * @throws \ErrorException
  * @throws \Exception
  */
 protected function processPage(Page $page, Data $config)
 {
     if ($config->get('responsive')) {
         $this->enableResponsiveness($config);
     }
     $container = $this->getEmbedContainer($config);
     $services = array_filter((array) $config->get('services', []), function ($service) {
         return !empty($service['enabled']);
     });
     $usedServices = [];
     $content = $page->content();
     foreach ($services as $serviceName => $serviceConfig) {
         $service = $this->getServiceByName($serviceName, $serviceConfig);
         $content = $service->processHtml($content, $container, $processedCnt);
         if ($processedCnt > 0) {
             $usedServices[] = $serviceName;
         }
     }
     if (!empty($usedServices)) {
         $this->defineAssets($page, $config, $usedServices);
     }
     return $content;
 }
开发者ID:biggtfish,项目名称:grav-plugin-videoembed,代码行数:30,代码来源:videoembed.php

示例5: processPage

 /**
  * Twig process that renders a page item. It supports two variations:
  * 1) Handles modular pages by rendering a specific page based on its modular twig template
  * 2) Renders individual page items for twig processing before the site rendering
  *
  * @param  Page   $item    The page item to render
  * @param  string $content Optional content override
  * @return string          The rendered output
  * @throws \Twig_Error_Loader
  */
 public function processPage(Page $item, $content = null)
 {
     $content = $content !== null ? $content : $item->content();
     // override the twig header vars for local resolution
     $this->grav->fireEvent('onTwigPageVariables');
     $twig_vars = $this->twig_vars;
     $twig_vars['page'] = $item;
     $twig_vars['media'] = $item->media();
     $twig_vars['header'] = $item->header();
     $local_twig = clone $this->twig;
     // Get Twig template layout
     if ($item->modularTwig()) {
         $twig_vars['content'] = $content;
         $template = $item->template() . TEMPLATE_EXT;
         $output = $local_twig->render($template, $twig_vars);
     } else {
         $name = '@Page:' . $item->path();
         $this->setTemplate($name, $content);
         $output = $local_twig->render($name, $twig_vars);
     }
     return $output;
 }
开发者ID:qbi,项目名称:datenknoten.me,代码行数:32,代码来源:Twig.php


注:本文中的Grav\Common\Page\Page::content方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。