i use MVC and i want to change my url!I want to put my product's title in url.
look at this one
domain.com/buy/read/51
and i want something like this
domain.com/buy/read/some_text.
what is the best Optimal Solution???
domain.com/controllers/function/parameter
51 is parameter,i cannot remove it from url.can i?
after above problem,i decide to make a url like this
domain.com/buy/read/51/some_text
and attempt to change it with(by htaccess)
domain.com/buy/some_text
but i couldnot.
please help me.i spend 3 days with this problem.
It's depend of your framework (even it's your own). Usually, you can create a Route which match with your constraints.
Sorry if i can't help more, but i need more informations
Bye
i declared this codes in Bootstrap.what's your opinion??
if(isset($url[0]) && $url[0]=='buy'){
require 'controllers/buy.php';
$controller=new buy();
$controller->Read($url[1]);
return FALSE;
}
Related
Trying to find help for this problem has taken me to a whole new one: complete lack of ressources, books and samples vor MVC 4 in VB.NET. I am having to choose between learn by experience (and the associated feeling of banging your head against a wall) or give it up and move to C# alltogether.
No company should ship a product if they are not willing to give it the same support as its sibling pruduct. They should drop VB for MVC completely or give us the means to learn it.
With that out of the way, here's my question. This line:
#Html.EditorFor(Function(x) x.UsersData(temp).Roles(Role))
Is a nice line of code. Works wonders. But How can I add a class to it, so I can change the style on my css files?
Well, it seems that this should do the trick:
#Html.EditorFor(Function(x) x.UsersData(temp).Roles(Role), New With {.class = "users-manage-check-box"})
But guess what, it doesn't. Ever. The result is the same.
What is wrong and how can I fix it?
And to be completely honest, I did come up with a solution. One that makes me feel dirty.
Looking at the output from that code, i see that the boxes classes are "check-box".
So what I've been doing is this:
#html.Raw(Html.EditorFor(Function(x) x.UsersData(temp).Roles(Role), New With {.class = "users-manage-textbox"}).ToHtmlString.Replace("check-box", "user-manage-checkbox"))
This feels wrong. So wrong. And not only is it a sad piece of code, it introduces security risks, which I'll have to fix before my solution is out of the development phase.
Any clues on why the additional view data is not working as it should? Am I getting something wrong? Am I asking too much?
Thanks a lot!
I don't think EditorFor allows that. So you need to create a custom editor template yourself.
You can read more about creating custom templates in this blog post
Update:
Take a look at the answer for this issue from http://aspnetwebstack.codeplex.com/
This behavior is by design.
The overload that you are calling accepts an object parameter called
additionalViewData (http://msdn.microsoft.com/en-us/library/ff406462).
The default implementation of EditorFor ignores this value. You would
have to write a custom editor template to be able to access that
information.
I am working on a project and was wondering if anyone else has messed with the view model much. Im looking for some examples on how to inject other view models i.e header,footer content.
I already have the template and layout path switching Im just trying to figure out the best way to handle if I select layout1 and it has 3 footer content fields, and a slider so how would put a class in front of the render to gather and inject required data
EDIT
Ok I guess I should clarify LOL .... slight ADHD where my mind wanders.
What should I listen for before injecting the viewmodels or can I do this in my onBootStrap() in my main module. I currently
$sites = $e->getApplication()->getServiceManager()->get('Application\Model\Sites');
$sr = $sites->getSiteByDomain();
Since many domains and/or subdomains can point to this and puts info in a session. Maybe im over thinking it and should just extend actionController like I did in ZF1
LOL PHP so many ways to do something ......
Thx for any pointers
There's two helpful links i can give you. One is the playground of Rob Allen alias Akrabat, you can find his playground right over here at github. The other one would be the official documentation which is nicely documented on this part.
If those don't help you, you should specify your question and show us what you've tried so far.
I am using ColdFusion 9.0.1.
I have a new web site that uses Bikes.cfm and Makers.cfm as template pages. I need to be able to pass BikeID and MakerID to both of the these pages, along with other variables. I don't want to use the Actual page name in the URL, such as this:
MyDomain.com/Bikes.cfm?BikeID=1234&MakerID=1234
I want my URL to look more like this:
MyDomain.com/?BikeID=1234&MakerID=1234
I need to NOT specify the page name in the URL.
I want these two URLs to access different data:
MyDomain.com/?BikeID=1234&MakerID=1234 // goes to bike page
MyDomain.com/?MakerID=1234&BikeID=1234 // goes to maker page
So, if BikeID appears in the URL before MakerID, go to the Bikes.cfm page. If MakerID appears before BikeID, go the Makers.cfm page.
Is there an easy and existing method to arrange the URL keys in such a way to have them point to the appropriate page?
Should I just parse the the URL as a list and determine the first ID and go to the appropriate page? Is there a better way?
Any thoughts or hints or ideas would be appreciated.
UPDATE -- It certainly appears that using the order of parameters in a URL is a bad idea for the following reasons:
1) many programs append variables to the URL
2) some programs may reorder the variables
3) GoogleBot may not consider order relevant and will most likely not index the site correctly.
Thanks to everyone who provided advice in a positive manner that my approach was probably a bad idea and would not produce the results I wanted. Thanks to everyone who suggested alternate means to produce the results I wanted.
If anyone of you positive people would like to put your positive comment/advice as an answer, I'd be happy to accept it as the answer.
Despite my grave misgivings about the whole idea, here's how I would do it if I were forced to do so:
index.cfm:
<cfswitch expression="#ListFirst(cgi.query_string, '=')#">
<cfcase value="BikeID">
<cfinclude template="Bikes.cfm">
</cfcase>
<cfcase value="MakerID">
<cfinclude template="Makers.cfm">
</cfcase>
<cfdefaultcase>
<cfinclude template="Welcome.cfm">
</cfdefaultcase>
</cfswitch>
I've got a need where each user can customize their own page on a replicated site. In grails it seems the most straightforward way to do this is:
somedomain.com/someController/JohnDoe
spelling out a controller, except this forces folks to type in a longer domain name, versus something like
somedomain.com/JohnDoe
Using sub-domains may be another approach, however they would need to be created automatically, i.e. when someone joins.
Can you please clarify the main ways Grails supports this kind of requirement/need (replicated site), and some of the pros/cons of each?
Thanks, Ray
Edit: Per Tomasz's edit below, the simplest course of action isn't clear. If you have insights on this please do share.
It is called UrlMappings in grails. You need to declare:
"/$username?" {
controller = 'someController'
action = 'user'
}
It redirects to someController, action user and optional variable called username.
This solution has one catch. Every one level path you visit passes this rule and takes you to someController. You cannot go to somedomain.com/books because it passes rule above and it follows you to someController#user with params['username']='books'. Then you can't use default actions. But if you decide that all your other paths have at least one slash, e.g. /books/list then you can follow this solution
Edit: I was wrong. It doesn't work as I've expected. I thought that UrlMappings are applied in order they are defined. That's not true, as explained here. Even worse - it's not documented (GRAILS-6246). Most specific explanation comes from Peter Ledbrook :
It uses a specificity algorithm, so the most specific match should apply
You must experiment then. I suggest you use safest solution and stick with /user/username solution.
I'm starting a new site project in Codeigniter. I need this site to be multilingual, where English will be the default language.
I know how the language class in codeigniter works, and I am already using it.
My concern is that I need the URL to be shown in the selected language. I'll explain myself with an example:
When English language is selected, I have this URL:
www.domain.com/cars/list_cars
where cars is the controller and list_cars is the method in charge of calling the appropriate view.
When Spanish language language is selected, I would like the URL to show as
www.domain.com/coches/mostrar_coches
Which is the best way to achieve this? The only way I can think of is by changing routes.php with something like:
$route['cars/list_cars'] = 'coches/mostrar_coches';
Is there any better/easier way of achieving this?
Thanks!
I built the concebe.com with CodeIgniter and Url translated. My solution was to redirect all requests to only one controller, which is responsible for calling other functions depending on the translation. see below:
function dinamic($js,$page,$item=NULL,$id=NULL)
{
switch ($page)
{
case $this->lang->line('products'):
$page='products';
break;
case $this->lang->line('about_us'):
$page='about_us';
break;
...
}
//switch page
switch ($page)
{
case 'contact_us':
$this->template->render($js,$this->_contact_us($js));
return;
break;
}
This is not a clever solution and don't help you too, because is harder, but I have to differentiate the js call also, and this was the only way, I hope this help someone.
Constrains:when switch language, you lose the page were you where.
I did what you propose, using routes.php for your localised url segments. Works fine for me but for every page you do need a new entry in your routes file.
Translating your controller and method names is a headache waiting to happen. The benefits to your SEO are so minimal that it is really not worth doing, just make sure you have good content.