Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

How to get $file_path when "SEF" and "Normalize Friendly URLs" are enabled

Asked Modified Viewed 1,127 times
S
sasha2002
S
  • Junior Member, joined since
  • Contributed 26 posts on the community forums.
  • Started 9 threads in the forums
  • Started this discussions
asked
Junior Member

Hi,
When "Search Engine Friendly URL (SEF)" AND "Normalize Friendly URLs" are enabled have this for Homepage :

Path to File:
Request URI: index.php
1. index.php : No matching Alias found.
2. index.php : No matching Alias Pattern found.
3. File path is empty.

How is possible to get "$file_path" ?
Want to do something like that :
$is_home = 'index.php' == $file_path;
O other pages i got :
Path to File: infusions/articles/articles.php
Request URI: articles
and $file_path="/articles"

And second question is: How i can get title of the Page for "function render_page() {"
$title here does not have power
0 replies

3 posts

R
Anonymous User
R
Anonymous User 367
  • Veteran Member, joined since
  • Contributed 939 posts on the community forums.
  • Started 2 threads in the forums
  • Answered 20 questions
answered
Veteran Member

Quote

How is possible to get "$file_path" ?

$file_path = str_replace(ltrim(fusion_get_settings('site_path'), '/'), '', preg_replace('/^//', '', FUSION_REQUEST));
if (fusion_get_settings('site_seo') && defined('IN_PERMALINK')) {
 $file_path = \PHPFusion\Rewrite\Router::getRouterInstance()->getCurrentURL();
}

if ($settings['opening_page'] == $file_path) {
 // content visible only on homepage
}


Quote

How i can get title of the Page for "function render_page() {"

Use this function https://php-fusion.co.uk/docs/phpfusi...t_settings
Print $settings variable to see available settings, page title should be on top.
0 replies
S
sasha2002
S
  • Junior Member, joined since
  • Contributed 26 posts on the community forums.
  • Started 9 threads in the forums
  • Started this discussions
answered
Junior Member

I've got "" on $file_path.
And no page title in $settings. This is var_dump

array(133) {
 ["sitename"]=>
 string(31) "REDACTED"
 ["siteurl"]=>
 string(23) "https://site.com/"
 ["site_protocol"]=>
 string(5) "https"
}
Edited by Anonymous User on 26-10-2021 12:58,
0 replies
R
Anonymous User
R
Anonymous User 367
  • Veteran Member, joined since
  • Contributed 939 posts on the community forums.
  • Started 2 threads in the forums
  • Answered 20 questions
answered
Veteran Member

Quote

I've got "" on $file_path.

Here is another solution
if (fusion_get_settings('site_seo')) {
   $params = http_build_query(\PHPFusion\Rewrite\Router::getRouterInstance()->getFileParams());
   $path = \PHPFusion\Rewrite\Router::getRouterInstance()->getFilePath();
   $file_path = '/'.(!empty($path) ? $path : PERMALINK_CURRENT_PATH).($params ? "?" : '').$params;
} else {
   $file_path = '/'.PERMALINK_CURRENT_PATH;
}

if (fusion_get_settings('opening_page') == 'index.php' && $file_path == '/' || $file_path == '/'.fusion_get_settings('opening_page')) {
   // content visible only on homepage
}

I'll add function for this to core, there are many situations when you need to display something only on homepage.

Quote

And no page title in $settings.

render_page() function displays current page layout and not custom pages. Specify what you want..

'sitename' is page title or if you want entire current title, there is function https://php-fusion.co.uk/docs/phpfusi.../get_title


Btw. here is template for Custom pages, you can copy this code into your theme and modify it https://github.com/PHPFusion/PHPFusio...ge.tpl.php
0 replies

Category Forum

SEO & SEF - 9

Labels

None yet

Statistics

  • Views 0 views
  • Posts 3 posts
  • Votes 0 votes
  • Topic users 2 members

2 participants

S
S
  • Junior Member, joined since
  • Contributed 26 posts on the community forums.
  • Started 9 threads in the forums
  • Started this discussions
R
R
Anonymous User 367
  • Veteran Member, joined since
  • Contributed 939 posts on the community forums.
  • Started 2 threads in the forums
  • Answered 20 questions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet