Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION How to alter urls and title ?
#1
Lightbulb 
Hello all,

I'm trying to create a simple plugin, something like catalog..

I've tried to change title by doing


PHP Code:
global $title;
$title "new title"

but this doesn't work..
another thing is, what is the best way to implement url structure in GS ?


I'm using something like this:

Code:
RewriteRule ^catalog/(.+)?\/(.+)?\/(.+)?$ index.php?id=catalog&main=$1&sub=$2&detail=$3 [QSA,L]
RewriteRule ^catalog/(.+)?\/(.+)?$ index.php?id=catalog&main=$1&sub=$2 [QSA,L]
RewriteRule ^catalog/(.+)?$ index.php?id=catalog&main=$1 [QSA,L]
+
PHP Code:
if (isset($_GET['id']) && $_GET['id']=="catalog") {
 
   if(!empty($_GET['detail'])) {
 
       add_filter('content''detail_list');
 
   }
 
   elseif(!empty($_GET['sub'])) {
 
       add_filter('content''sub_list');
 
   }
 
   elseif(!empty($_GET['main'])) {
 
       add_filter('content''main_list');
 
   }
 
   else add_filter'content''all_list' );


Thanks for any feedback !
Reply
#2
I think someone made a route plugin
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#3
I know, but using plugin for a plugin isn't ideal solution. I think you mean Extra Router.

What about the title? is there a way how to replace the title ? Or am I triggering wrong hook for it ?
Reply
#4
Ohh i see

Umm title for what a specific page, non existant page?
What hook are you using?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#5
Yes, I need to change title (and <title> tag) in every generated page. Content comes from json files updated by cron every 12 hours (in real, it updates records once in a week maybe), so everything is basically outside of GS, only "catalog" page is there as a placeholder with metadata and for custom template file if needed.

I tried to use index-pretemplate, content-top hooks but nothing changed, content filter works fine for displaying data in page content, but there is no filter for titles in 3.3
Reply
#6
(2016-10-18, 16:24:28)morvy Wrote: I tried to use index-pretemplate, content-top hooks but nothing changed, content filter works fine for displaying data in page content, but there is no filter for titles in 3.3

I tried to use following and both seems to work well:

Code:
add_action('index-pretemplate', '__change_page_data');
function __change_data() {
    global $title;
    $title = 'My Title';
}

Code:
add_filter('data_index', '__change_page_data');
function __change_page_data() {
    global $data_index;
    $data_index->title = 'My Title';
        $data_index->content = 'Here's my content';
    return $data_index;
}
Reply
#7
Thanks, something new that I didn't know about (data_index stuff). Both tricks work, but only for return_page_title in <head>, when calling the same function in <body> I see original title (Catalog)
Reply
#8
I can't imagine that, unless you use cached content
Reply
#9
Switched to default template and worked fine, so I did a research of my custom functions and found out that breadcrumbs are causing this issue Sad it was using $title so it replaced it there.

problems fixed, thank you guys again for your help!
Reply
#10
Why not have your cron job just update the xml pages files titles?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#11
Shawn, it's nearly 700 entries that need to remain in json because it's used elsewhere too .. so having GS with 700 pages in menu structure would be overkill
Reply
#12
I see.

I would use data_index filter for all of this, since globals are set from data_index and other plugins might be using either.

one hook and you just inject your entire phantom page.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#13
The front end router plugin is what I was referring to, but it was buggy.

I have my own fork i was fixing up.
https://github.com/tablatronix/gs-front-..._dataindex

https://github.com/lokothodida/gs-front-router/issues/5
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#14
the router thing looks too difficult for my scenario, so those 3 lines in htaccess seem fine for now.

$data_index is pretty cool Smile I'm using it also for other fields now, so I can reuse different template and join local and remote entries Smile
Reply
#15
My history is having the url http: // a and I want to switch to https://... [MODERATOR NOTE: SPAM - NON GS SITE - REMOVED], what should I do?
Reply
#16
(2019-10-01, 16:56:34)trantulong Wrote: My history is having the url http: // a and I want to switch to [...], what should I do?

    http://get-simple.info/wiki/security:https-ssl

    How to setup GetSimple on HTTPS/SSL

    As of 3.0, you will be able to install GetSimple with a SSL certificate.
    Install as you normally would
    Confirm the “Website Base URL” is set with the https protocol.

    Go to the backend and open the Admin and set there the website base url
    Empty the cache

    Be sure that all files within your theme and plugins are using https in the url
    Check that all your pictures are linked to https

    If something is still not working after moving to https
    load all the pages from /data and /data-subdirectories into a good code editor, f.e. notepad++ (not Word!)
    do a global search and replace, update the URLs of all objects which refer to http://www.olddomain.tld
    to https. After that, upload these updated files to your server
Reply
#17
I also recommend adding to the file .htaccess
Code:
RewriteCond %{ENV:HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Reply




Users browsing this thread: 2 Guest(s)