CakePHP 2.1 custom url for pagination links - pagination

I am using cakephp 2.1 and I defined pagination links in 'latest' view. Its showing controller and action names in url like
/pages/latest/page:2.
But I want only action name in url like
/latest/2.
Please suggest me how to do that?.. The work will be more appreciable..

You could define custom routes.
Routing in CakePHP also encompasses the idea of reverse routing, where an array of parameters can be reversed into a string url. By using reverse routing, you can easily re-factor your applications url structure without having to update all your code.
http://book.cakephp.org/2.0/en/development/routing.html
e.g.
Router::connect(
'/latest/:number',
array('controller' => 'pages', 'action' => 'view'),
array('pass' => array('number'))
);

Related

Applying infinite scroll upon wooocmmerece site isn't working as expected

I'm trying to implement jetpack's infinite scroll. my website has ?currency_switch=EUR and ?orderby=width-desc these kinds of custom URL parameters, which are successfully implemented without any ajax and for search I am using relevanssi.
I am using this code in my functions.php
function mytheme_infinite_scroll_init() {
add_theme_support( 'infinite-scroll', array(
'container' => 'multiple-products',
'type' => 'scroll',
'posts_per_page' => get_option( 'posts_per_page' )
) );
}
add_action( 'init', 'mytheme_infinite_scroll_init' );
It works (only at the shop page) but doesn't work with the custom url parameters as mentioned above and breaks for search.I didn't tweak any code for pagination(didn't alter any $paged stc).
How to handle it for custom query params? How to deal with relevanssi as it states that it doesn't support the jet pack plugin's infinite scroll feature, is there a way to make relevanssi results infinite scrollable via jet pack.
I tried my custom implementation , as a start tried making a simple ajax call but i am ending up with weird issues like this A simple Ajax call in wordpress doesn't give the expecetd output
Thanks
Sorry for the boring answer, but there's no way to make Relevanssi work with the Jetpack Infinite Scroll feature. You just need to disable it on search pages, as described in Relevanssi knowledge base.

How to mask url and write our own URL JSF

I want to mask my JSF urls, to customization purpose.
For Example:
If url is : http://localhost:8080/myapp/mypages/index.xhtml
I want to mask it as : http://localhost:8080/MyApp/Home
I want do like this for all urls of my application.
I'm sorry If this is repeated question,! If there is any similar on JSF question please point it out I'll delete this question.

CakePHP 2 Pagination woes

I am having a problem getting the precise URL needed when using pagination in CakePHP 2.1.3 which needs to be the same as my custom route. Here is an example of what I have:
URL: /courses/section-name/cat-name/subcat-name
My route:
Router::connect('/courses/:section/:cat/:subcat/*', array(
'controller' => 'courses', 'action' => 'courseCategory'), array(
'pass' => array('section', 'cat', 'subcat'),
'section' => '[a-zA-Z0-9_-]+',
'cat' => '[a-zA-Z0-9_-]+',
'subcat' => '[a-zA-Z0-9_-]+'
));
Everything works fine in terms of normal navigation using this format and when visiting a page I get paginated results okay with all my links etc. I have set my Paginator Helper 'options' as follows:
$this->Paginator->options(array('url'=>$this->passedArgs));
This however produces a URL like eg: /courses/courseCategory/section-name/cat-name/subcat-name/page:2 which does not work.
If I manually remove the action name 'courseCategory' from the URL eg: /courses/section-name/cat-name/subcat-name/page:2 etc, then everything works fine and I go to the relevant page of results, so I guess I am close? However, after many hours of searching, reading the docs/API and trying different things I just cannot get my URL links to appear without the controller's action and it's now driving me mad!
So, I guess the question is either where am I going wrong or does anybody have an alternative solution to this?
Any help would be greatly appreciated & happy to provide more info if needed.
Thanks :)

URL Rewrites for magento custom module

I am trying to create some user friendly URLs for my module.
The module name is landing. Right now, I use the index controller and index action, and then grab a string "page" from the URL an grab my object based on that. So, my URLs look like this:
http://www.example.com/landing/index/index/page/CoolPage
My current idea is to structure this url as /landing/{page}, so that it would be just:
http://www.example.com/landing/CoolPage
At first, I tried accomplishing this using htaccess. I have the following:
RewriteRule ^landing/([a-z\-]+)(/)?$ landing/index/index/page/$1 [R,L]
Which works but does a redirect instead of a rewrite. I also tried it with just [L] and without the [] on the end, but I just end up at my 404 page.
Ideally I would use a config rewrite, as that could be packaged with my module, but I can't find any documentation on using them like this. I would be happy using .htaccess or even a db based rewrite, if it worked as desired.
Is there a way to do a rewrite like this in Magento?
I think I had the exact same request from a client some time ago and here is how I managed it, which I think is the easiest and simpliest way...
Actually, it is possible to make a rewrite right into your module's config.xml file.
In this example, all URLs like
http://www.domain.com/landing/whatever
will be rewritten to
http://www.domain.com/landingpage/page/view/whatever
Config.xml
<?xml version="1.0"?>
<config>
<modules>
<My_LandingPage>
<version>0.0.1</version>
</My_LandingPage>
</modules>
<frontend>
<routers>
<landingpage>
<use>standard</use>
<args>
<module>My_LandingPage</module>
<frontName>landingpage</frontName>
</args>
</landingpage>
</routers>
</frontend>
<global>
<!-- Rewrite requested routes -->
<rewrite>
<my_landingpage_page_view>
<from><![CDATA[#^/landing/#]]></from>
<to>/landingpage/page/view/</to>
<complete>1</complete>
</my_landingpage_page_view>
</rewrite>
</config>
Controller
<?php
class My_LandingPage_PageController extends Mage_Core_Controller_Front_Action {
/**
* View page action
*/
public function viewAction() {
// Get the requested path (/landing/whatever)
$pathInfo = $this->getRequest()->getOriginalPathInfo();
// Extract the requested key (whatever)
$pathArray = explode('/landing/', $pathInfo);
$requestedKey = $pathArray[1];
// So, from there you can use $requestedKey to load any model using it.
// This is also where you will load and render your layout.
}
}
Side note about layout
As the real controller action that is called is "landingpage/page/view", if you need some layout for this module, its handle will be <landingpage_page_view>.
This is a textbook custom router case if I've ever seen one. You can take the approach of the CMS router and adjust the path on the request object so that your controllers can match using the Standard router.
Your other alternative is to create an indexer to create rewrites for your module's entities and store them in the core_url_rewrite table.

Joomla - Custom component url rewrite

I have the following component #
?option=com_tmportal&module=user&task=main
I've enabled url rewriting and setup the htaccess file which is all working correctly, how would I create a rewrite rule that allows me to access the component above by simply doing:
/portal/ = ?option=com_tmportal
or
/portal/user = ?option=com_tmportal&module=user
or
/portal/user/main = ?option=com_tmportal&module=user&task=main
Thanks for any help, much appreciated :)
You haven't specified Joomla version so I'm assuming 1.6/7/2.5 in my answer.
Short Answer: If you're using Joomla!'s default .htaccess then all you have to do is create a Joomla! menu to each of your components views with the right alias eg. portal for your default component access ie. ?option=com_tmportal.
This is what the default .htaccess does it passes all of the elements after the base URL to index.php to help select the component and view.
Longer Answer
When you create a component for Joomla! you specify the menu settings for each view using an XML file usual the same name as the view file in it's view/tmpl/ directory.
Typically the url to a specific view & task in a component would look like these:
?option=com_mycomponent
?option=com_mycomponent&view=userdetails
?option=com_mycomponent&view=userdetails&task=main
Joomla!'s framework will automatically use the view & task params to get your components correct controller and view (or sub-view). I'm not sure that it does anything with the module param that you have in your URL's so I'd guess you're trapping and processing that yourself.

Resources