Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
4078a0aa
Commit
4078a0aa
authored
Sep 07, 2017
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add function qa_get_canonical to auto-generate canonical URL
Also add canonical tag to question lists and tag pages.
parent
f51af14b
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
5 deletions
+31
-5
page.php
qa-include/app/page.php
+23
-0
q-list.php
qa-include/app/q-list.php
+2
-0
tag.php
qa-include/pages/tag.php
+2
-0
tags.php
qa-include/pages/tags.php
+2
-0
users-newest.php
qa-include/pages/users-newest.php
+1
-2
users.php
qa-include/pages/users.php
+1
-3
No files found.
qa-include/app/page.php
View file @
4078a0aa
...
...
@@ -828,3 +828,26 @@ function qa_get_state()
global
$qa_state
;
return
$qa_state
;
}
/**
* Generate a canonical URL for the current request. Preserves certain GET parameters.
* @return string The full canonical URL.
*/
function
qa_get_canonical
()
{
$params
=
array
();
// variable assignment intentional here
if
((
$start
=
qa_get_start
())
>
0
)
{
$params
[
'start'
]
=
$start
;
}
if
(
$sort
=
qa_get
(
'sort'
))
{
$params
[
'sort'
]
=
$sort
;
}
if
(
$by
=
qa_get
(
'by'
))
{
$params
[
'by'
]
=
$by
;
}
return
qa_path_html
(
qa_request
(),
$params
,
qa_opt
(
'site_url'
));
}
qa-include/app/q-list.php
View file @
4078a0aa
...
...
@@ -124,6 +124,8 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl
$qa_content
[
'page_links'
]
=
qa_html_page_links
(
qa_request
(),
$start
,
$pagesize
,
$count
,
qa_opt
(
'pages_prev_next'
),
$pagelinkparams
);
}
$qa_content
[
'canonical'
]
=
qa_get_canonical
();
if
(
empty
(
$qa_content
[
'page_links'
]))
{
$qa_content
[
'suggest_next'
]
=
$suggest
;
}
...
...
qa-include/pages/tag.php
View file @
4078a0aa
...
...
@@ -79,6 +79,8 @@ foreach ($questions as $postid => $question) {
qa_post_html_fields
(
$question
,
$userid
,
qa_cookie_get
(),
$usershtml
,
null
,
qa_post_html_options
(
$question
));
}
$qa_content
[
'canonical'
]
=
qa_get_canonical
();
$qa_content
[
'page_links'
]
=
qa_html_page_links
(
qa_request
(),
$start
,
$pagesize
,
$tagword
[
'tagcount'
],
qa_opt
(
'pages_prev_next'
));
if
(
empty
(
$qa_content
[
'page_links'
]))
...
...
qa-include/pages/tags.php
View file @
4078a0aa
...
...
@@ -70,6 +70,8 @@ if (count($populartags)) {
}
else
$qa_content
[
'title'
]
=
qa_lang_html
(
'main/no_tags_found'
);
$qa_content
[
'canonical'
]
=
qa_get_canonical
();
$qa_content
[
'page_links'
]
=
qa_html_page_links
(
qa_request
(),
$start
,
$pagesize
,
$tagcount
,
qa_opt
(
'pages_prev_next'
));
if
(
empty
(
$qa_content
[
'page_links'
]))
...
...
qa-include/pages/users-newest.php
View file @
4078a0aa
...
...
@@ -83,8 +83,7 @@ if (!empty($users)) {
$qa_content
[
'title'
]
=
qa_lang_html
(
'main/no_active_users'
);
}
// set the canonical url based on possible pagination
$qa_content
[
'canonical'
]
=
qa_path_html
(
qa_request
(),
(
$start
>
0
?
array
(
'start'
=>
$start
)
:
null
),
qa_opt
(
'site_url'
));
$qa_content
[
'canonical'
]
=
qa_get_canonical
();
$qa_content
[
'page_links'
]
=
qa_html_page_links
(
qa_request
(),
$start
,
$pageSize
,
$userCount
,
qa_opt
(
'pages_prev_next'
));
...
...
qa-include/pages/users.php
View file @
4078a0aa
...
...
@@ -74,9 +74,7 @@ if (count($users)) {
$qa_content
[
'title'
]
=
qa_lang_html
(
'main/no_active_users'
);
}
// set the canonical url based on possible pagination
$qa_content
[
'canonical'
]
=
qa_path_html
(
qa_request
(),
(
$start
>
0
?
array
(
'start'
=>
$start
)
:
null
),
qa_opt
(
'site_url'
));
$qa_content
[
'canonical'
]
=
qa_get_canonical
();
$qa_content
[
'page_links'
]
=
qa_html_page_links
(
qa_request
(),
$start
,
$pagesize
,
$usercount
,
qa_opt
(
'pages_prev_next'
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment