Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

[Solved] HTML Title for the CustomPage Plugin

mclovinmclovin New
edited November 2011 in Vanilla 2.0 - 2.8
Anyone knows how to override the HTML page title for a custom page created by the custom page plugin?

Best Answers

  • ToddTodd Chief Product Officer Vanilla Staff
    edited November 2011 Answer ✓
    I'm not 100% familiar with the plugin, but the following should work if you put it in the custom page php file:
    $this->SetData('Title', 'Foo');
    or
    $this->Head->Title('Foo')
    Those both do something slightly different, so try them both out and see what you like.
  • ToddTodd Chief Product Officer Vanilla Staff
    Answer ✓
    Oh okay, I think Gdn::Controller() may be in the current release then. Just try $this->SetData('Title', 'Foo').

Answers

  • ToddTodd Chief Product Officer Vanilla Staff
    edited November 2011 Answer ✓
    I'm not 100% familiar with the plugin, but the following should work if you put it in the custom page php file:
    $this->SetData('Title', 'Foo');
    or
    $this->Head->Title('Foo')
    Those both do something slightly different, so try them both out and see what you like.
  • mclovinmclovin New
    edited November 2011
    @Todd

    Here is what the custom plugin code looks like:
    public function PluginController_Page_Create(&$Sender) {
    // See what page was requested
    $Page = ArrayValue('0', $Sender->RequestArgs, 'default');
    ..............
    $Path = PATH_PLUGINS . DS . 'CustomPages' . DS . 'pages' . DS;
    ............
    $Sender->Title('Generic title for all custom pages');
    $Sender->MasterView = $MasterView;
    $Sender->Render($Path.$Page.'.php');
    }
    Then on the default.php which is a custom page, I dont think I can do:

    Gdn:Controller()->Head->Title('Foo')


  • ToddTodd Chief Product Officer Vanilla Staff
    Did you try it?
  • ToddTodd Chief Product Officer Vanilla Staff
    You do, it's global. It should point to the same thing as $this in the view.
  • mclovinmclovin New
    edited November 2011
    @Todd
    I tried

    <?php Gdn::Controller()->SetData('Title', 'Foo'); ?>
    or
    <?php Gdn:Controller()->Head->Title('Foo')?>

    It says:
    Fatal error: Call to undefined method Gdn::controller() in ......
  • ToddTodd Chief Product Officer Vanilla Staff
    Answer ✓
    Oh okay, I think Gdn::Controller() may be in the current release then. Just try $this->SetData('Title', 'Foo').
  • Awesome. Worked perfectly. Thank you @Todd.
Sign In or Register to comment.