I am beginner at symfony and I've been confused about couple things, well my website has a header where user can search,select language and manage his account and i have a navigation menu and a footer that is common between all my website pages , so i created a commonbundle where i put the common code for header and menu and footer i also created a global layout where i included my header controller,menu controller and footer controller, i don't know if this approach is correct and im already having problem about how to do following stuff:
include the search bundle in my header
get the current request in header as it returns a subrequest
generate url in my header because i have no route for it as it doesn't suppose to have one because we'll never call it .
You can follow this to help with setting up fragments:
http://symfony.com/blog/new-in-symfony-2-2-the-new-fragment-sub-framework
As for getting the top level request, try:
$this->container->get('request');
i did a search about it and found that : you cannot redirect from an embedded controller as we only get the response content. With the current architecture, I don't think it is even possible and anyway, I'm not sure we want to support this feature.
https://github.com/symfony/symfony/issues/2517
Related
I am having tourble creating and routing static pages from within the Sylius CMS.
I have had this working once but now just can not get it to work at all. Creating the content for the page works fine but when I try to save a route all I get is errors.
An exception has been thrown during the rendering of a template
("Parameter "id" for route "sylius_backend_static_content_update" must
match ".+" ("" given) to generate a corresponding URL.") in
SyliusWebBundle:Backend/Content/StaticContent:update.html.twig at line
20.
Image of the page I am trying to save
Any help would be appreciated as there doesn't seem to be any documentation on this part of sylius.
May be you can have a look into the link below. I also had some problems with the routes while creating the pages. I had solved it by adding some info into the database. Hope this link helps you.
https://github.com/Sylius/Sylius-Standard/issues/78
Happy Syliusing ^^
Inside my _layout view I have added the following link , to refresh the current page as part my breadcrumb bar:
#(aoutput == "Index" ? "Home" : aoutput)
The above is working well on my development environment , but I am not sure If using the Request.Url.AbsoulteUri is the correct way to reference the current page URL ?
AbsoluteUri includes the scheme (such as http), the host, the port, the path, query string data and the fragment. As far as I know the fragment will not be included in the current URL because it is not sent with the request (that is, it's handled by the browser client-side).
This should be fine to use and is unlikely to cause you issues. Just be aware that query string data is included, which means that if you had a (poorly-designed) data manipulation system such as /Users/Index?action=deleteMostRecentUser then the user might accidently delete users because the URI would include the action.
Alternatives are
Absolute Path: /Home/Index
Path & Query: /Home/Index?query=keyword
You can use it as you mentioned.
Better way you make a separate partial view to implement breadcrumb.
And pass wanted model from Controller side. (Or in ViewBag)
The main benefit is you'll get is better control over Logic also flexible for future changes.
Hope helps.
I've created a project with the moovweb sdk and have trouble editing the content within an iframe on one of the pages. For instance, moving a div around inside the iframe doesn't seem to work with the tritium I'm writing. What can I do with tritium to make this work? The domains are different FYI.
Unfortunately, Tritium only allows you to edit the attributes of the iframe itself, not the content within.
This is because the request for content in the iframe is made after the browser constructs the DOM of the main page. Tritium can only intercept the first request for the main page, not the second request for content from a different domain.
I know of two workarounds:
Add the second website as a Moovweb project and you will be able to use Tritium to manipulate the content. Then you can point the iframe of the original page to this new content.
Use JavaScript/AJAX to modify the iframe's content.
However there are implications for production domains... I'm afraid I may have rushed this answer and will update it after I do more research.
If the iframe is on the same origin (http://m.yoursite.com) or on an origin you have in your config.json you can absolutely use tritium! However, maybe not in the way you expect!
So, the iFrame is going to make a separate request to the src attribute's location. If you ensure this request is going through the SDK (by rewriting it) like so:
$(".//iframe[#src]") {
attribute("src") {
rewrite("link")
}
}
Then you can map that url and perform your regular tritium on it!
you need to analyses the src of iframe and need to write mapping in mappings.ts for the url in src. Include proper .ts file in pages folder and start transforming it.
I have a dynamic PHP stylesheet, but I can't find a way to send variables to it so I used sessions instead. Figured this kinda sucked, so I'm going to give it another try but could need some help. It's an external stylesheet where a variable has effect through the whole document.
You probably want to use an embedded stylesheet (a <style> block) in the page: it increases the size of the main page, but solves the variable access issue without needing sessions and reduces your number of requests. You can just load your dynamic stylesheet into the main page's view using load->view.
EDIT: Ah, massive amounts of CSS would be one problem. Well, two alternatives are to:
Turn on the $_GET support in your CI install, you COULD pass in a request parameter in the CSS link and then check for the request parameter in the PHP controller or view file that generates the actual CSS. Not visually the tidiest option, but it does work.
Put in a cookie that you check in the controller that gets called for the CSS: you can then check that in the controller or view and do the right thing. Visually much tidier than the request parameter option, but a bit more involved.
I have a view page that accepts a taxonomy term id as an argument at /foo/%bar. I want to add several menu items to the primary links in the form of /foo/actual-bar.
Whenever I try to do this I get the error message "The path '/foo/actual-bar' is either invalid or you do not have access to it."
How can I add such menu items?
Thanks,
Finbarr
Off the top of my head I believe there are a couple ways to do this:
Use absolute URLs (http://yoursite.com/foo/actual-bar) in the menu, which should bypass the check.
Define the links in a custom module using hook_menu()
It does seem to me that there should be a better way to achieve this, but these two options should at least get your going in the short term.
Another way would be to set the url in the view to foo/% it makes the argument required and the 6.x menu system will then see it as a valid URL.
However, just /foo will no longer be a valid URL, so you may need to create another page display in the view to accommodate the URL with no argument.
i recommend set path in such way: /foo/%/bar
so you can access it via: /foo/actual/bar
Oddly, I have a custom module that defines a hook_menu but the menu UI won't allow me to enter it into the system.
Had to do the absolute path solution... though I sure don't like it!