This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

maxDubovsky
maxDubovsky

I need this in my own plugin and this refers to sitemap.xml and resolveNewsItem. Basicaly I can acheeve everything by manualy parsing the urls and later feed them into array of my rainlab.sitemap. But I want it to be in a nice a propper way, so here is a small problem:

    $locale = "en";
    $theme = \Cms\Classes\Theme::getActiveTheme();
    $page = \Cms\Classes\Page::loadCached($theme, "news/news-open");
    $page->rewriteTranslatablePageUrl($locale);
    $itemUrl = url($locale."".$page->url, ['slug' => 'this-is-my-blog-post']);
    var_dump($itemUrl);

Result:

    string(52) "http://www.ms.localhost/en/news/:slug/this-is-my-blog-post"
Expected result: string(52) "http://www.ms.localhost/en/news/this-is-my-blog-post"
slug should be replaced with parameter.

Please help, can't understand what is wrong

maxDubovsky
maxDubovsky

Working example: $locale = "lv";

    $theme = \Cms\Classes\Theme::getActiveTheme();
    $page = \Cms\Classes\Page::loadCached($theme, "news/news-open");

    $page->rewriteTranslatablePageUrl($locale);

    $router = new RainRouter;
    ............ foreach (){
            $localeUrl = $router->urlFromPattern($locale."".$page->url, ['slug' => $blog->slug]);
            $branchItem['url'] = URL::to($localeUrl);

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.