I am using routes in Zend Framework 1.
Currently I'm having a number of nested categories, all displayed in the URL. An URL can be of the following forms:
www.example.com/category/1-category/2-subcategory/3-subsubcategory
www.example.com/category/4-category/5-subcategory
www.example.com/category/6-category
And longer.. Here 1 is a root category, with 2 being a child and 3 a grandchild. I am only interested in the ID of the last child in the URL, which are 3, 5 and 6 above.
I can't find a nice way to handle all URLs.
I've declared some routes in the Bootstrap file (only displaying the routes, not the full declarations):
/category/:c/:a/:t/:e/g:/:category
/category/:c/:a/:t/:e/:category
/category/:c/:a/:t/:category
/category/:c/:a/:category
/category/:c/:category
In this order, the right route will be picked with the category variable sent to the controller, giving me the result I want. However, all declarations are the same and take up 6 lines of code, only differing one variable.
This results in a very ugly piece of code, but I can't find a way to write this nicely. Is there a nice way?
If you want to define less number of routes in bootstrap than you can use * for dynamic routes but some times dynamic routes become less user friendly. For example:
/category/:c/:category/*
Related
We have dictionary under /content/dam for languages say (en-us, es-us) . When we load the page its injected and we have the translated content render on the page. As part of the requirement I have some doubts to clarify.
When I load the page, I see multiple calls of /libs/cq/i18n/dict.xxx.json, how can we restrict default dictionary calls?
/libs/cq/i18n/dict.en.json
/libs/cq/i18n/dict.en-US.json (We need only this one)
/libs/cq/i18n/dict.en.json
My custom dictionary /libs/cq/i18n/dict.en-US.json has only 5 labels, but in response i see via <%= slingRequest.getResourceBundle(slingRequest.getLocale()).keySet()%><br> , numbers of other labels may be injected via /libs/cq/i18n/dict.en.json
Is there way to load /libs/cq/i18n/dict.en-US.json as per site level. Say, I want to load the dictionary on /content/mySiteA/en-US and not on /content/mySiteB/en-US ? keeping in consideration that codebase is same.
Am using $GLOBALS['TSFE']->cObj->typoLink to generate a link and I've an additional parameter like this: ext__pluginname[d64]=31511 and would like to return something like a/b/c. I would then want TYPO3 to give me back the link so I can resolve it when clicked. I've already tried PersistedAliasMapper but won't allow to return anything with a slash in it. I've even tried a custom aspect mapper. I get the error:
Parameter "tx_ext__pluginname__d64" for route "enhancer_tx_ext__pluginname000000003e62d21a000000000514759a" must match "[^/]++" ("a/c" given) to generate a corresponding URL.
Am able to generate and resolve the slugs(urls). I can store them in db and retrieve them for that matter. No problem.
Am generating them from root page (uid 1).
How can i get this to work?
I assume you already have created the desired path in a database table or view already, making use of the slug feature in the TYPO3 backend or creating it yourself.
You could then use the PersistedAliasMapper in your site config (config/sites/default/config.yaml).
If you need multiple values in a single path divided by slashes (not a combined slug field), take a look at the route configuration for the news extension. You just have to use database mappers instead of static ones, but keep in mind this may impact the performance of the routing!
As you did not provide much detail about your use case, I don't really understand why you need such a path structure with slashes.
I'm trying to crawl a site and to do so, I'm using Scrapy. So, when doing requests to nested pages, the procedure usually gets the the information correctly on the first trials, but, on later requests the nodes starts to return None. I'm using xpath's functionality. Below I'm pasting some lines of the parse function:
(I tried this one with the approach of explicitly comparing the class value)
title = response.xpath('//span[#class="inlineFree"]/text()').extract_first()
(With this one I used the contains function)
view = response.xpath('//span[contains(#class,"count")]/text()').extract_first()
(I've also used this one when I found more suitable)
comments = response.css('div.commentMessage > span::text').extract()
Am I doing something wrong on paths?
Is there any reason for the crawler to stop reading the nodes correctly?
Cannot say what the problem is without the log messages or the spider code but..
What happens most of the time is that websites fo not follow a strict html structure .For some properties the 'title' may be inside the span
but for the next iteration it may be
span[#class="inlineFree"]/h1/text() or or any other tag
so you should check the html for those returning None
I have mount Page in this form (with one predefined parameter):
mountPage("/lista/${variant}", StronaEntityV2.class);
when parameter "variant" is given all is OK. But when parameter is absent (is OK too from application point of view) URL is build in form
wicket/bookmarkable/all....package...StronaEntityV2?8
It is ok too, but I will know that situation. In simple situation (with one predefined parameter) checking parameter is good, but in more complicated isn't so simple (and must maintain code in distinct places).
My ideal imaged solution is event
page.OnPageIsMountedOn(URL to_me)
I will accept wide range of solutions.
FORMAL: please integrate synonyms on tags wicket-1.6 & wicket-6, and create new wicket-7
Your page is configured to listen to /lista/${variant}.
When you do: setResponsePage(StronaEntityV2.class, paramsWithVariant) then Wicket will use the mount point and produce: /lista/variantValue.
But if you do: setResponsePage(StronaEntityV2.class), i.e. no PageParameters provided, then Wicket will ignore /lista/${variant} (because it doesn't match) and will produce a "default" page url, i.e. /wicket/bookmarkable/com.example.StronaEntityV2.
So the application controls which url should be used.
You can use optional parameter placeholder: /lista/#{variant}. Note that I use # instead of $ now. This way Wicket will produce /lista/ when there is no variant parameter provided. In the page constructor you will know that the url is always "/lista" but the parameter may be null, so better use: pageParameters.get("variant").toXyz(defaultValue) or .toOptionalXyz().
I have several controllers which I want to match with the usual router pattern. These include: users, organisations, products. They should be accessible via, for example:
/users/login
/users/edit
/organisations/edit
/organisations/add
/products/view
etc...
If the first segment of the URI does not match a controller name, then I want to assume it is the name of an organisation. It should then call the browse controller, with the organisation name as a user parameter.
I can see how to satisfy the second part of the problem, i.e. calling the browse controller. (I will simply create and register a new Zend_Controller_Router_Route()).
How can I get the first part working though?, ie. how can I configure a route to lookup a list of controllers?
The only solution I can think of is to register a static route for each controller, however I'm not sure I can pass user parameters this way. Also, it would mean creating a large number of routes...
Any ideas?
One way I could think of now, is to first collect all your controller names and exclude them in your rule like this.
(!users|!products).*