•  · 15 friends

Page Title Placeholder

What placeholder should I used to change the title of the Keyword Search page to be something like this:

Search Results for {Keyword_Search_word} in {Search_Module} 

0 0 0 0 0 0
  • 140
Replies (11)
  • Hello Scholar !

    To prevent the change of core's files it would be better to add the RAW block there with the code like this one:

    <script>

      $(document).ready(function () {

        var sKeyword = $('-form-element-keyword input[name="keyword"]').val();

        if (sKeyword !='')

        {

          document.title += ' ' + sKeyword;

        }

      });

    </script>

    You may also add there the scan results for the used sections (modules).

    0 0 0 0 0 0
    • Thanks, that's useful information!

      0 0 0 0 0 0
      • Hi LeonidS, this works fine with the webpage but not very well with SEO and crawlers. Where in the UNA code we might be able to add a method to change the pate title based on the search quiries / url generated?

        0 0 0 0 0 0
        • LeonidS any idea where to start?

          0 0 0 0 0 0
          • In the given code you need to add the part which will grab the "section" input variants.

            0 0 0 0 0 0
            • I meant where to start in UNA PHP code. I tried the JavaScript code but it does not work with SEO crawlers. it only works on browsers. We want to hard code this in UNA code. which class / method is responsible for generating the title of the Keyword Search page results?

              0 0 0 0 0 0
              • You may try to add the code of the page.php file directly to searchKeyword.php. Just change this part:

                require_once("./page.php");

                to those:

                $oPage = BxDolPage::getObjectInstanceByURI('', false, true);

                if ($oPage) {

                    $oPage->displayPage();

                } else {

                    $oTemplate = BxDolTemplate::getInstance();

                    $oTemplate->displayPageNotFound();

                }

                Then before the  $oPage->displayPage(); add the parsing of the GET / POST argument about modules and keyword and then pass it to the template class. It will look like:

                if ($oPage) {

                    // your parsing code here

                    $oTemplate = BxDolTemplate::getInstance();

                    $oTemplate->setPageHeader(given new page header);

                    $oPage->displayPage($oTemplate);

                }

                0 0 0 0 0 0
                • LeonidS I've tried your code without parsing the GET request. Unfortunately, it didn't work with a simple string 'testing the new title'. 

                  <?php
                  require_once('./inc/header.inc.php');
                  require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
                  $_GET['i'] = 'search-keyword';
                  $oPage = BxDolPage::getObjectInstanceByURI('', false, true);
                  if ($oPage) { 
                  $oTemplate = BxDolTemplate::getInstance(); 
                  $oTemplate->setPageHeader('testing the new title'); 
                  $oPage->displayPage($oTemplate);
                  } else {
                  $oTemplate = BxDolTemplate::getInstance();
                  $oTemplate->displayPageNotFound();}
                  0 0 0 0 0 0
                  • Ok, then try this variant of code:

                    $oPage = BxDolPage::getObjectInstanceByURI('', false, true);

                    if ($oPage) {

                        $oTemplate = BxDolTemplate::getInstance();

                        $oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);

                        $oTemplate->setPageType ($oPage->getType());

                        $oTemplate->setPageInjections ($oPage->getInjections());

                        $oTemplate->setPageHeader(/* new header */);

                        $oTemplate->setPageContent ('page_main_code', $oPage->getCode());

                        $oTemplate->getPageCode();

                    } else {

                        $oTemplate = BxDolTemplate::getInstance();

                        $oTemplate->displayPageNotFound();

                    }

                    0 0 0 0 0 0
                    • this does not work as well. it keeps showing the default title 'Search by Keyword' title 😐 

                      0 0 0 0 0 0
                      • Do you have the possibility to provide the files access?

                        0 0 0 0 0 0
                        Not logged in users can't 'Comments Post'.
                        6
                        5
                        1
                        Added:
                        Category:

                        UNA - Social Media Software Framework

                        Close