The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom Page Title
#1
Hi,

How can I have a custom page title per page? It is currently set from
Code:
usersc/includes/head_tags
, however, if I want each page to have its own page title, how can I achieve this?
  Reply
#2
Sorry for the slow response. It's been a crazy week. If you look in users/helpers/helpers.php one of the first functions is

Code:
function currentPage() {
Code:
$uri = $_SERVER['PHP_SELF'];
Code:
$path = explode('/', $uri);
Code:
$currentPage = end($path);
Code:
return $currentPage;
Code:
}

So, basically what you could do is make a database table (page_titles) that has 3 columns

id (int 11, auto incremented, primary key)
page (varchar 255)
title (text)

So then you would write something along the lines of...

Code:
$cp = currentPage();
Code:
$currentPageQ = $db->query("SELECT * FROM page_titles WHERE page = ?,"array($cp));
Code:
$currentPage = $currentPageQ->first();

Then you can do your head tag by echoing

Code:
$currentPage->title;

Hope that helps
  Reply
#3
Thanks for your response, I'll try it out.
  Reply
#4
In header.php this code is found:
Code:
<title><?=$settings->site_name;?></title>

The title kan be changed on the fly, without changing us files:
<pre>
Code:
<script type="text/javascript">

    $(document).ready(function() {
        document.title = 'blah';
    });

</script>
</pre>
  Reply
#5
That's a great workaround, thanks! We're nearing the end of work on version 4.3 and this feature will soon be built in, but this Javascript snippet will work until then.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)