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} 

  • 429
  • More
Replies (14)
    • 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).

      • Thanks, that's useful information!

        • 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?

          • LeonidS any idea where to start?

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

              • 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?

                • 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);

                  }

                  • 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();}
                    • 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();

                      }

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

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

                          • I do most of the experimenting on my local UNA on a AMPPS server.

                            • Do we can add to title what whe search and to meta description? Like in another modules (display name). Thanks.

                              • Hello Rocco !

                                It's possible only via code modifications like above.

                                Login or Join to comment.