Custom component extension development

11 years 9 months ago - 11 years 9 months ago #6677 by dsd3mon
Hello!

I wrote a component and I need to write SEF Advance extension for it. I successfully had written a simple router using this tutorial: www.sakic.net/support/sef_advance_extensions/ (only changing in custom component strings doesn't work for me for some reason).

One of my problem is that sometimes I doesn't need component name in SEF URL.
For example, i have link in next format: index.php?option=com_foo&somevar=somevalue. All that i can get from here is /foo/somevalue, but what i need is /somevalue. Of course, I took care that somevalue is not a components or folders name. I clearly understand that there is a parsing problem, but is this possible? I just don't want to write parser plugin by my own or look for some other components, because most of them stores data in db and in my case it will be a lot of records (I had a big problem with this a couple of years ago using AceSEF)

Second, I am going to need something like this for another component. The link has the next format: index.php?option=com_bar&view=somestaicvalue&id=id. What I need is SEF link like this /otherstaticvalue/id. Is this possible?

Also, when I am writing an extension I should always think about different vars. Can I just skip them and they then append to the end of my URL?
For example, for some component i dont need much SEF. My link is  index.php?option=com_foo&task=sometask and I want not to think about the task, but SEF Advance unset it. What i want is /foo?task=sometask, but I've got just /foo.

I hope there is a chance to resolve my problems.

Dmytro Solop.

Please Log in or Create an account to join the conversation.

11 years 9 months ago #6678 by Saka
Hello,

It's possible to write a SEF extension which would skip component name but it's tricky. I did this for K2 and for some custom implementations of jReviews. Basically this would work only for sites that only use that component instead of regular content. If the site uses Joomla content component and K2 and jReviews and Foo, then it's likely SEF Advance will get confused. Component name in URL (which is replaceable) offers a simple separation for its logic.

If you want to give it a try you can set
var $skip_prefix = true;
under class sef_foo and component name will be skipped. But be aware that this is not recommended if you don't know what you are doing.

You can append parameters as query string in SEF Advance URL. It should not reset them. Maybe it wouldn't work with option, view, task and some other reserved parameters but should work with the rest.

Emir Sakic
www.sakic.net

Please Log in or Create an account to join the conversation.

11 years 9 months ago #6679 by dsd3mon
Thank you for your response.

I tried to add $skip_prefix property and change it depending of url when bulding but i've got very strange results. Extension built SEF URL with link to a deleted component item. I tried to figure out how skip_prefix  works, but then I gave up and resolved my problem by editing JRouterSite class. May be this is not the best way to do this, and with time I'll find some side effects, but it work fine.
So, I decided to route and parse some components with JRouterSite, and with the rest SEF Advance will take care.

Dmytro Solop

Please Log in or Create an account to join the conversation.

About us

We provide high quality Joomla components created by a co-founder and original core developer of Joomla. For over a decade, our products have been used by more than 20.000 webmasters around the world.

Stay in touch