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}
-
-
·
LeonidS
- ·
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 = $('
#bx-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).
-
·
LeonidS
-
- · Victoria
-
·
In reply to LeonidS
- ·
Thanks, that's useful information!
-
- · Scholar
-
·
In reply to LeonidS
- ·
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?
-
- · Scholar
-
·
In reply to Scholar
S
- ·
LeonidS any idea where to start?
-
-
·
LeonidS
-
·
In reply to Scholar
S
- ·
In the given code you need to add the part which will grab the "section" input variants.
-
·
LeonidS
-
- · Scholar
-
·
In reply to LeonidS
- ·
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?
-
-
·
LeonidS
- ·
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
-
- · Scholar
-
·
In reply to LeonidS
- ·
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();}
-
-
·
LeonidS
-
·
In reply to Scholar
S
- ·
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();
}
-
·
LeonidS
-
- · Scholar
-
·
In reply to LeonidS
- ·
this does not work as well. it keeps showing the default title 'Search by Keyword' title 😐
-
-
·
LeonidS
-
·
In reply to Scholar
S
- ·
Do you have the possibility to provide the files access?
-
·
LeonidS
-
- · Scholar
-
·
In reply to LeonidS
- ·
I do most of the experimenting on my local UNA on a AMPPS server.
-
- · Rocco
- ·
Do we can add to title what whe search and to meta description? Like in another modules (display name). Thanks.
-
-
·
LeonidS
-
·
In reply to Rocco
- ·
Hello Rocco !
It's possible only via code modifications like above.
-
·
LeonidS