Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Publisher and Template Routes

Status Resolved
Add-on / Version Publisher 2.0.0
Severity
EE Version 3.5.12

Aaron Jay

Mar 22, 2018

Description:

Hi, does Publisher with EE’s Template Routes?  I have a url as follows: http://mysite.com/en/text/terms-and-conditions.  I want to remove the text part of the URL so I just have http://mysite.com/en/terms-and-conditions

I’ve set up routes as in the screenshot below.

I can get to http://mysite.com/en/terms-and-conditions and I can get to http://mysite.com/fr/terms-and-conditions but when I try and route out the template name and translate the url, for example: http://mysite.com/fr/termes-et-conditions, the channel entries tag does not return any content. 

The channel entries tag I’m using is:

{exp:channel:entries channel="text_pages" url_title="{publisher:last_segment}” limit=“1” dynamic=“no” require_entry=“yes”}

{title}

{/exp:channel:entries}

I can get the fully translated entry, including the URL title if I leave the template name in.  The link below work fine:

http://mysite.com/fr/text/termes-et-conditions


Detailed steps to reproduce the issue:
1. enable url translation
2. translate the entry including the url title
3. use template routes to route out the template name

#1

BoldMinded (Brian)

Yes, it works with template routes. Have you tried anything else besides {publisher:last_segment} as the url_title parameter? Did you print out {publisher:last_segment} outside of the entries tag to see if its the correct value? Did you try segment_1, or segment_2? Publisher’s routes settings work exactly like the native routes, so make sure you follow the docs closely.

#2

Aaron Jay

Hi Brian,

Thanks for your help.

{publisher:last_segment} outside the entries tag gives the correct last segment translated and untranslated

In the last segment I’ve tried:

{publisher:last_segment} {last_segment} {segment_1}

The three above work for untranslated url, but not for the translated one.

If I hard code an entry id, entry_id=”5” for example, this works fine, I can remove the segment and translate the url

Do I need to do anything with Publishers routes? I’ve set this up in EE’s Template Routes

#3

Aaron Jay

Hi Brian,

Just a quick update on this, I’ve being playing around with it and I’ve noticed that if I use:

{exp:channel:entries channel=”text_pages” url_title=”{publisher:segment_1}” dynamic=”no”} {if no_results} Show if no results {/if} {/exp:channel:entries}

On the version with the translated url title, I get the content in the if no results tag. Seems like it’s not matching the translated URL title to the entry?

#4

BoldMinded (Brian)

Did you define anything in the Publisher Routes settings?

#5

Aaron Jay

I tried a few things but nothing seems to save in the routes field. I might not be putting the right thing in anyway, I’m not entirely sure what I should be putting in there to be honest.

Am I in the right place? I’ve gone to Template Translations and I can see the text templates with fields for Template and Route.

What should I putting in here? I couldn’t see anything in the docs about it.

#6

BoldMinded (Brian)

So I can try to replicate this locally, what is text and terms-and-conditions? Is text a template group, and terms-and-conditions a template name?

#7

Aaron Jay

Hi Brian,

Thanks again for your help.

So I have a Channel called Text Pages.

In this channel I have an entry called Terms and Conditions

I’m using a group called text.group

In the text.group I have Index.html with the following tag:

{exp:channel:entries channel=”text_pages” url_title=”{publisher:last_segment}”} <div class=”o-header”> <h1>{title}</h1> {/exp:channel:entries}

This will give me a URL of : http://mysite.com/en/text/terms-and-conditions

This works fine for the regular and translated version

I want to use EEs template routes to remove the text part, just giving me http://mysite.com/en/terms-and-conditions

this works fine, but the translated URL http://mysite.com/fr/termes-et-conditions does not display anything in between the channel entries tag

I mentioned earlier, if I add

exp:channel:entries channel=“text_pages” url_title=”{publisher:segment_1}”} {if no_results} Show if no results {/if} <div class=”o-header”> <h1>{title}</h1> {/exp:channel:entries}

I get the content in the if no_results tag, on the translated version, but not on the non translated version

#8

BoldMinded (Brian)

This might have been a bug elsewhere not related to template routes, but to replicate the issue I added the variable {url_title} to my template translations for that template

https://www.dropbox.com/s/q6lt6i5cyp454xy/Screenshot 2018-03-23 14.51.03.png?dl=0

I set the default route to the same value (using EE4 here)

https://www.dropbox.com/s/vs1itmtzmjlfqwd/Screenshot 2018-03-23 14.52.05.png?dl=0

Used the following template code

={segment:url_title}=
={publisher:last_segment}=
={publisher:segment_1}={segment_1}=
{exp:channel:entries channel="text_pages" url_title="{publisher:last_segment}"}
  <h1>{title}</h1>
{/exp:channel:entries}

And it renders the page correctly

https://www.dropbox.com/s/owfvp8j5j8qdqyj/Screenshot 2018-03-23 14.53.13.png?dl=0

I think the issue was that the {publisher:last_segment} value contained the translated value, not the default. The next comment will have a link to the the latest build.

#9

BoldMinded (Brian)

Comment has been marked private.

#10

Aaron Jay

Hi Brian,

I tried to install that, but I’m getting some PHP errors and it seems to be trying to install Publisher Lite, is that right?

#11

BoldMinded (Brian)

That is definitely not a Publisher Lite build. If you’re getting errors, I need to see what they are. Please copy/paste them here. Thanks.

#12

Aaron Jay

Hi Brian,

No problem, Is there a way to include screenshots in here?

I’ve copied the themes and user folder in EE that you provided and when I go to Add On Manager, it now says Publisher Lite and the following errors are at the top of the page:

Notice Use of undefined constant PUBLISHER_LITE - assumed ‘PUBLISHER_LITE’ user/addons/publisher/language/english/lang.publisher.php, line 6

Notice Use of undefined constant PUBLISHER_AUTHOR_URL - assumed ‘PUBLISHER_AUTHOR_URL’ user/addons/publisher/addon.setup.php, line 32

Notice Use of undefined constant PUBLISHER_DOCS_URL - assumed ‘PUBLISHER_DOCS_URL’ user/addons/publisher/addon.setup.php, line 33

Warning Cannot modify header information - headers already sent by (output started at ee/legacy/core/Exceptions.php:119) ee/EllisLab/ExpressionEngine/Boot/boot.common.php, line 531

If I try and look at the front end of the site I get:

Notice Use of undefined constant PUBLISHER_LITE - assumed ‘PUBLISHER_LITE’ user/addons/publisher/ext.publisher.php, line 889 show details

Severity: E_NOTICE Notice Use of undefined constant PUBLISHER_LITE - assumed ‘PUBLISHER_LITE’ user/addons/publisher/ext.publisher.php, line 893 show details

Severity: E_NOTICE Notice Use of undefined constant PUBLISHER_AUTHOR_URL - assumed ‘PUBLISHER_AUTHOR_URL’ user/addons/publisher/addon.setup.php, line 32 show details

Severity: E_NOTICE Notice Use of undefined constant PUBLISHER_DOCS_URL - assumed ‘PUBLISHER_DOCS_URL’ user/addons/publisher/addon.setup.php, line 33 show details

Severity: E_NOTICE Notice Use of undefined constant PUBLISHER_LITE - assumed ‘PUBLISHER_LITE’ user/addons/publisher/mod.publisher.php, line 287 show details

Severity: E_NOTICE Notice Use of undefined constant PUBLISHER_LITE - assumed ‘PUBLISHER_LITE’ user/addons/publisher/Service/Url/Url.php, line 649 show details

Severity: E_NOTICE Notice Use of undefined constant PUBLISHER_LITE - assumed ‘PUBLISHER_LITE’ user/addons/publisher/mod.publisher.php, line 287 show details

Severity: E_NOTICE Notice Use of undefined constant PUBLISHER_LITE - assumed ‘PUBLISHER_LITE’ user/addons/publisher/Service/Url/Url.php, line 649 show details

Severity: E_NOTICE Notice Use of undefined constant PUBLISHER_LITE - assumed ‘PUBLISHER_LITE’ user/addons/publisher/Service/Url/Url.php, line 649 show details

Severity: E_NOTICE Warning Cannot modify header information - headers already sent by (output started at ee/legacy/core/Exceptions.php:119) ee/EllisLab/ExpressionEngine/Boot/boot.common.php, line 531 show details

Severity: E_WARNING

#13

BoldMinded (Brian)

Those errors seem like all of the files have not been updated. Those constants are defined in the addon.setup.php file…. are you sure its present in that environment?

#14

Aaron Jay

Hi Brian,

When I copied in the new folders, I left the old folders in place, just with a _ in front of them.

Deleting the old folders entirely, now show the update button and the correct version of publisher. But when I click on the update to 2.7.7 button, I get the error below:

Exception Caught SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘1-1-1-open-0-1’ for key ‘phrase_unique_index’: ALTER TABLE exp_publisher_phrase_data ADD UNIQUE phrase_unique_index (phrase_id, site_id, lang_id, status, is_auto, edit_by) ee/legacy/database/drivers/mysqli/mysqli_connection.php:122

Stack Trace: hide details

0 ee/legacy/database/drivers/mysqli/mysqli_driver.php(137): CI_DB_mysqli_connection->query(‘ALTER TABLE `ex…’)

1 ee/legacy/database/DB_driver.php(297): CI_DB_mysqli_driver->_execute(‘ALTER TABLE `ex…’)

2 ee/legacy/database/DB_driver.php(203): CI_DB_driver->simple_query(‘ALTER TABLE `ex…’)

3 user/addons/publisher/updates/up_2_05_00.php(16): CI_DB_driver->query(‘ALTER TABLE `ex…’)

4 user/addons/publisher/vendor/litzinger/basee/src/Updater.php(95): Update_2_05_00->doUpdate()

5 user/addons/publisher/upd.publisher.php(610): Basee\Updater->runUpdates()

6 ee/EllisLab/ExpressionEngine/Controller/Addons/Addons.php(560): Publisher_upd->update(‘2.0.0’)

7 [internal function]: EllisLab\ExpressionEngine\Controller\Addons\Addons->update(Array)

8 ee/EllisLab/ExpressionEngine/Core/Core.php(189): call_user_func_array(Array, Array)

9 ee/EllisLab/ExpressionEngine/Core/Core.php(94): EllisLab\ExpressionEngine\Core\Core->runController(Array)

10 ee/EllisLab/ExpressionEngine/Boot/boot.php(151): EllisLab\ExpressionEngine\Core\Core->run(Object(EllisLab\ExpressionEngine\Core\Request))

11 admin.php(143): require_once(‘…’)

11 admin.php(143): require_once(‘…’)

#15

BoldMinded (Brian)

Looks like you’re encountering an old bug. Unfortunately the only way to fix it is to manually find those duplicate rows and remove them from the exp_publisher_phrase_data table.

#16

BoldMinded (Brian)

This query should find the duplicates

select distinct phrase_id, site_id, lang_id, `status`, is_auto, edit_by
  from exp_publisher_phrase_data as t1
 where exists (select * 
                 from exp_publisher_phrase_data as t2 
                where t2.id != t1.id
                  and t2.phrase_id = t1.phrase_id
                  and t2.site_id = t1.site_id
                  and t2.lang_id = t1.lang_id
                  and t2.`status` = t1.`status`
                  and t2.is_auto = t1.is_auto
                  and t2.edit_by = t1.edit_by
               )
#17

Aaron Jay

Hi Brian,

Thanks for that, but I’m getting the same thing. Is there a certain order I need to do this in?

I go to the database, paste the code above and run it.

It removes a lot of entries in that table

When I then try and update the plugin, I get the same error:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘1-1-1-open-0-1’ for key ‘phrase_unique_index’: ALTER TABLE exp_publisher_phrase_data ADD UNIQUE phrase_unique_index (phrase_id, site_id, lang_id, status, is_auto, edit_by) ee/legacy/database/drivers/mysqli/mysqli_connection.php:122

Stack Trace: hide details

0 ee/legacy/database/drivers/mysqli/mysqli_driver.php(137): CI_DB_mysqli_connection->query(‘ALTER TABLE `ex…’)

1 ee/legacy/database/DB_driver.php(297): CI_DB_mysqli_driver->_execute(‘ALTER TABLE `ex…’)

2 ee/legacy/database/DB_driver.php(203): CI_DB_driver->simple_query(‘ALTER TABLE `ex…’)

3 user/addons/publisher/updates/up_2_05_00.php(16): CI_DB_driver->query(‘ALTER TABLE `ex…’)

4 user/addons/publisher/vendor/litzinger/basee/src/Updater.php(95): Update_2_05_00->doUpdate()

5 user/addons/publisher/upd.publisher.php(610): Basee\Updater->runUpdates()

6 ee/EllisLab/ExpressionEngine/Controller/Addons/Addons.php(560): Publisher_upd->update(‘2.0.0’)

7 [internal function]: EllisLab\ExpressionEngine\Controller\Addons\Addons->update(Array)

8 ee/EllisLab/ExpressionEngine/Core/Core.php(189): call_user_func_array(Array, Array)

9 ee/EllisLab/ExpressionEngine/Core/Core.php(94): EllisLab\ExpressionEngine\Core\Core->runController(Array)

10 ee/EllisLab/ExpressionEngine/Boot/boot.php(151): EllisLab\ExpressionEngine\Core\Core->run(Object(EllisLab\ExpressionEngine\Core\Request))

11 admin.php(143): require_once(‘…’)

11 admin.php(143): require_once(‘…’)

#18

BoldMinded (Brian)

That query doesn’t remove anything, its just a select. You need to remove the rows manually because it’ll bring back multiple similar rows.

#19

BoldMinded (Brian)

Aaron, I’ve found some other issues with the template translation settings, which I don’t think are related to your issue, but would you be interested in testing the build to ensure that the changes are correct?

#20

Aaron Jay

Hi Brian, Sure that sounds great

#21

Aaron Jay

Hi Brian,

Just wondering if you’ve had a chance to look at this. Is the new version available anywhere?

#22

BoldMinded (Brian)

Yeah, 2.7.9 should be available in your account to download.

#23

Aaron Jay

HI Brian,

Thanks for that. I’ve tried to install that, but I’m still getting the same error.

So to walk through what I’ve done:

  1. I’ve gone to the exp_publisher_phrase_data table in the database and run the following SQL on it:

select distinct phrase_id, site_id, lang_id, status, is_auto, edit_by from exp_publisher_phrase_data as t1 where exists (select * from exp_publisher_phrase_data as t2 where t2.id != t1.id and t2.phrase_id = t1.phrase_id and t2.site_id = t1.site_id and t2.lang_id = t1.lang_id and t2.status = t1.status and t2.is_auto = t1.is_auto and t2.edit_by = t1.edit_by )

  1. Then I’ve gone to Addons on click the update button.

  2. I get the error below:

Exception Caught SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘1-1-1-open-0-1’ for key ‘phrase_unique_index’: ALTER TABLE exp_publisher_phrase_data ADD UNIQUE phrase_unique_index (phrase_id, site_id, lang_id, status, is_auto, edit_by) ee/legacy/database/drivers/mysqli/mysqli_connection.php:122

Stack Trace: hide details

0 ee/legacy/database/drivers/mysqli/mysqli_driver.php(137): CI_DB_mysqli_connection->query(‘ALTER TABLE `ex…’)

1 ee/legacy/database/DB_driver.php(297): CI_DB_mysqli_driver->_execute(‘ALTER TABLE `ex…’)

2 ee/legacy/database/DB_driver.php(203): CI_DB_driver->simple_query(‘ALTER TABLE `ex…’)

3 user/addons/publisher/updates/up_2_05_00.php(16): CI_DB_driver->query(‘ALTER TABLE `ex…’)

4 user/addons/publisher/vendor/litzinger/basee/src/Updater.php(95): Update_2_05_00->doUpdate()

5 user/addons/publisher/upd.publisher.php(614): Basee\Updater->runUpdates()

6 ee/EllisLab/ExpressionEngine/Controller/Addons/Addons.php(560): Publisher_upd->update(‘2.0.0’)

7 [internal function]: EllisLab\ExpressionEngine\Controller\Addons\Addons->update(Array)

8 ee/EllisLab/ExpressionEngine/Core/Core.php(189): call_user_func_array(Array, Array)

9 ee/EllisLab/ExpressionEngine/Core/Core.php(94): EllisLab\ExpressionEngine\Core\Core->runController(Array)

10 ee/EllisLab/ExpressionEngine/Boot/boot.php(151): EllisLab\ExpressionEngine\Core\Core->run(Object(EllisLab\ExpressionEngine\Core\Request))

11 admin.php(143): require_once(‘…’)

11 admin.php(143): require_once(‘…’)

Is there a certain order I need to do these in?

#24

BoldMinded (Brian)

Does running the query return any results? If so you need to determine which rows you need to delete manually. Just running the query alone won’t fix anything, it just identifies the duplicate rows.

#25

BoldMinded (Brian)

Closing because of no responses for 20 days.

Login to reply