Ajax and symphony
This is an open discussion with 8 replies, filed under General.
Search
I think, that best way is to set your xslt template to load only content if some parameter was set. Like this: _http://try.profilservis.ru/company/ and _http://try.profilservis.ru/company/?ajax=true
check _http://try.profilservis.ru/workspace/js/widgets.js for example
ok, i think i get what your saying, so to do that, i have to set url parameters in the page sattings to something like:
page=pagina
so i set my links to be something like:
http://mysite.com/?page=pagina
I know with that i get a parameter like $url-page = "pagina" in the parameters pool, but how do i make jquery load that?
I would the same and then use the parameter in the XSL in a <choose><when>
block. When the $url-page = pagina
output data only, otherwise spit out HTML.
well, i understand what you said just don´t know how to get it done in the code, could you give a hand and show me a exemple?
<xsl:template match="whatever"> <xsl:choose> <xsl:when test="$url-page = 'pagina'"> <xsl:apply-templates select="yournode" mode="html"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="yournode" mode="ajax"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="yournode" mode="html"> <!-- do stuff --> </xsl:template> <xsl:template match="yournode" mode="ajax"> <!-- do stuff --> </xsl:template>
ok so i made the following code keeping in mind you exemple:
<xsl:template match="data"> <xsl:apply-templates select="home/entry"/> </xsl:template> <xsl:template match="home/entry"> <xsl:choose> <xsl:when test="$nomePagina = ''"> <xsl:apply-templates select="entry" mode="home"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="entry" mode="ajax"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="entry" mode="home"> <xsl:apply-templates select="entry[@id='12']"> </xsl:template> <xsl:template match="entry" mode="ajax"> <xsl:apply-templates select="entry[@id=$entryID]"> </xsl:template> <xsl:template match="entry[@id='12']"> <div class="page_content" id="{titulo-da-pagina/@handle}"> <div class="banner_info"> <xsl:copy-of select="conteudo-html"/> </div> <div class="banner_img"> <img src="{$workspace}/{imagem/@path}/{imagem/filename}" alt="{titulo-da-pagina}" /> </div> </div> </xsl:template> <xsl:template match="entry[@id=$entryID]"> <div class="page_content" id="{titulo-da-pagina/@handle}"> <div class="banner_info"> <xsl:copy-of select="conteudo-html"/> </div> <div class="banner_img"> <img src="{$workspace}/{imagem/@path}/{imagem/filename}" alt="{titulo-da-pagina}" /> </div> </div> </xsl:template>
Does that look right?
Well the code works as it should, but as i´m using this with jquery load when i click the links in the menu e loads the hole page inside the ajax conteiner.
How do i load only another part of the xml using xsl?
It looks right, but you are not doing anything different in the two modes...
Also that $nomePagina
looks like a potentially weird criteria for switching modes, but I don't know what $nomePagina
means in your context, besides knowing that it means "page name".
By the way using XSLT as a switchboard is probably not ideal. I might suggest to rewrite URLs in a similar fashion, so you don't have to sweat it too much in XSL:
Normal URL: /somepage/someparameter
Points to what it says
Ajax bricks URL: /somepage/someparameter/ajax
Which gets rewritten by your server or URL Router extension to: /ajax/somepage/someparameter
This way you can use the same data sources, with the same URL parameters, but have the whole Ajax response handled by a different Symphony page.
Hope it helps. Takes time to figure out, but it pays off.
Create an account or sign in to comment.
I´m using jquery load() to pull pages content, but this creates a problem:
the link structure of my navigation is as fallow:
http://mysite.com/pages/page
and after the content has been loaded the link in the browser looks as fallow:
http://mysite.com/#page
As long people access my home page averything is good, but if they copy the links in my navigation and access that link, it only load that bit of content.
to axplain it better click here and check link
What i think i have to do is redirect the:
http://mysite.com/pages/page to http://mysite.com/#page
But one: i don´t know whats the best way to accomplish that. two: i really like a second opnion from some symphony experts if there is another way of doing this, thinking mostly about seo.
It is not going to be nice having google indexing those links, witch only contain a portion of the content.