Note that there are some explanatory texts on larger screens.

plurals
  1. PODrupal: hook_url_inbound_alter in url_rewrite: rewrite query part of URL for paging
    primarykey
    data
    text
    <p>I'm trying to use url_rewrite to work around nonfriendly parameters in URL of <code>paging</code> module. I wish to turn URLs like <code>page-title.html?page=0,1</code> to <code>page-title/page1.html</code>.</p> <p>Here are my hooks:</p> <pre><code>function mymod_url_outbound_alter(&amp;$path, &amp;$options, $original_path) { $localPath = $path . '?' . $options['query']; dpm("_url_outbound_alter($localPath)"); if (preg_match('|(.+)\.html\?page=0%2C(\d+)|', $localPath, $matches)) { $path = "${matches[1]}/page${matches[2]}.html"; unset($options['query']); dpm("altering path to $path"); } } function mymod_url_inbound_alter(&amp;$result, $path, $path_language) { if (preg_match('|(.+)/page(\d+)\.html|', $path, $matches)) { //$result = "${matches[1]}.html?page=0,${matches[2]}"; $result = "${matches[1]}.html"; //$_GET['q'] = "page=0,${matches[2]}"; $_GET['page'] = "0,${matches[2]}"; dpm("altering in-path to $result"); } } function mymod_boot() {} </code></pre> <p>Is it impossible to add query part in hook_url_inbound_alter? </p> <ul> <li>If I comment out mymod_url_outbound_alter, it works, bot comma us URL-encoded - OK, it did show the friendly URL.</li> <li>If I enable both, the page goes into infinite redirect 301 loop. </li> <li>The commented out variants also don't seem to work.</li> </ul> <p>Yes, I know it's better to fix <code>paging</code> to use non-query URL. But the module is a little too complex to do that reliably. <code>pagination</code> module lacks features for me.</p> <p>Is the problem in URL altering? What can I do to make it work?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload