2

I'm using RealURL in my Typo3 4.5.16 project for speaking URLs of a certain page. For this, I'm using a lookup-table that matches a certain number of IDs to their URL counterparts.

E.g.
http://www.example.com/path/to/catalog/chapter1/section1/group1/prod-123/
would map to page "catalog" with parameters mapped for chapter, section, group, and product, resp. Note that only the LAST of those parameters is relevant and has a real mapping, the others are only there for a "pretty" path.

Now my problem: not every product has all levels of preceeding path segments. For example, another product might have a URL like this:
http://www.example.com/path/to/catalog/chapter1/section4/prod-789/

The database would look like this:

Id  | seg0      | seg1      | seg2      | seg3      | dummy0    | dummy1    | dummy2    | MapId
----|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------
1   | chapter1  | section1  | group1    | prod-123  | 1         | 1         | 1         | 123
2   | chapter1  | section4  |           | prod-789  | 1         | 4         | 0         | 789

You see that the mapping to a segment name is just empty.

RealURL would however use an empty string as the group, and produce
chapter1/section4//prod-789

Is there a way to suppress such an empty mapping? Will decoding pass the segment to the next parameter (like noMatch => bypass for value maps)

If not, can multiple path segments be mapped at once using lookup table? (i.e. mapping the whole path to the real ID)?

king_nak
  • 11,313
  • 33
  • 58

2 Answers2

1

You might want to try hooks that realUrl provides, see this article

Tomaž Zaman
  • 318
  • 3
  • 9
0

Well, I found a hacky workaround myself.

It uses userFunctions, that basically mimic the behaviour of lookupTable. For every level there is one such function. It modifies the $params['pathParts'] array that is passed to the unser functions

Encoding:

  • For the "parent" levels, just map to the segment. This will return empty strings if not mapped.
  • For the mapped level, remove all empty elements at the end of the passed $params['pathParts'] array
  • => Removes empty parts

Decoding:

  • For the "parent" levels, check if there are more elements in $params['pathParts']. If not, this is a "skipped" parent. Just append the current value to the $params['pathParts'], which will be passed to the next level by RealURL
  • The mapped level eventually is called with the correct value. Just map

It works as long as the handling of userFunctions is not changed too much by RealURL...

king_nak
  • 11,313
  • 33
  • 58