2

I am using EE3 with Transcribe module and LowSeg2Cat extension.

I have URL with transcribe prefix i.e., abc.com/en/group/page/category_url_title

When I tried to get Category URL Title I can use the code {segment_3} but if I want category ID I cannot use {segment_3_category_id} as it returns nothing.

If I use {segment_4_category_id} It returns category ID of segment 3 (As segment_1 [en] is not a segment as per transcribe)

2

This is as designed.

Low Seg2Cat creates its own instance of EE's URI class, because add-ons like Transcribe (and specifically Structure) tend to rewrite the original URI instance, which rewrites the segment array into something else, which can lead to other unexpected results.

Low Seg2Cat therefore uses the URI as is, including "prefixes". You'll need {segment_4_category_id} (or alternatively {last_segment_category_id}).

1
  • 1
    Thank you for your response. I really appreciate it. As I have many pages where I cannot use last_segment_category_id I go with custom solution. I open ext.low_seg2cat.php and alter line 372 and add this code $prefix = array('en/', 'nl/', 'de/'); for ($i=0; $i < count($prefix); $i++) { if (substr($this->uri->uri_string, 0, strlen($prefix[$i])) == $prefix[$i]) { $this->uri->uri_string = substr($this->uri->uri_string, strlen($prefix[$i])); } } :) Mar 17 '17 at 9:09
1

I appreciate response of @Low. Thank you sir. As I have many pages where I cannot use {last_segment_category_id} or {segment_[n+1]_category_id}. I needed some quick hack in LowSeg2Cat extension to make it compatible with Transctibe module.

I open extension file via FTP and alter line number 372 from:

if ($this->settings['ignore_pagination'] == 'y')
{
    // Get rid of possible pagination segment at the end
    $this->uri->uri_string = preg_replace('#/[PC]\d+$#', '', $this->uri->uri_string);
}

To:

if ($this->settings['ignore_pagination'] == 'y')
{
    // Get rid of possible pagination segment at the end
    $this->uri->uri_string = preg_replace('#/[PC]\d+$#', '', $this->uri->uri_string);
}

/*Hack edit by MUFI to work with Transcribe module START*/
$prefix = array('en/', 'nl/', 'de/');
for ($i=0; $i < count($prefix); $i++)
{ 
    if (substr($this->uri->uri_string, 0, strlen($prefix[$i])) == $prefix[$i]) {
        $this->uri->uri_string = substr($this->uri->uri_string, strlen($prefix[$i]));
    }
}
/*Hack edit by MUFI to work with Transcribe module END*/

Where $prefix is an array of the Language abbreviation you are using in your site.

(I am still waiting for any solution that not make me open the plugin file and alter it.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.