ExpressionEngine pagination: access last segment - seo

I am working on some search engine optimisation for my expression engine site. I need to add some link tags into my head to allow google crawlers to acknowledge the relationship between paginated pages in my blog.
I need to add:
<link rel="next" href="http://www.mysite.com/news/latest-news/P10" />
to the first news page, then:
<link rel="prev" href="http://www.mysite.com/news/latest-news/" />
<link rel="next" href="http://www.mysite.com/news/latest-news/P20" />
to the next page, and some on until the final page where I'll add
<link rel="prev" href="http://www.mysite.com/news/latest-news/PXX" />
I have been trying to achieve this by using the following code:
First news page:
{if last_segment == "latest-news"}
<link rel="next" href="http://www.6dg.co.uk/news/latest-news/P10" />
{/if}
This works fine, but for subsequent pages I have tried this, which does not work as PX is not accessible as a url segment.
{if last_segment == "P10"}
<link rel="prev" href="http://www.6dg.co.uk/news/latest-news" />
<link rel="next" href="http://www.6dg.co.uk/news/latest-news/P20" />
{/if}
{last_segment} returns latest-news.
Does anyone know how I can get round this issue?
I also have another issue with this method. Currently I only have 3 paginated pages, but this will go up as more entries are added, so I am not going to know what segment value to target in order to add my final link tag.
Any help will be greatly appreciated.
I am using expressionengine version 2.2.2

This is actually a really tricky question. There's no native way to accomplish this in EE, so you'd have to write a custom add-on to do this properly.
You might want to delete this and instead post it over on the new ExpressionEngine StackExchange, where you'll have more capable eyes on it.

Related

Manage CSS Assets By Page (Odoo)

What is the best way to incorporate css / js assets into Odoo's website where the assets are only loaded for a particular page?
In the examples and documentation they speak of dumping your assets into Odoo's website.assets_frontend and I do this however there are circumstances where I would like to use website templates found online and I really do not want to take the time to look through the css classes and identify conflicts.
If the page itself were to fail that is one thing but if it breaks all the css on my existing pages that is another.
I was thinking of using a technique like this.
t-if="request.httprequest.path.startswith('/page/path/')"
Using an if statement to determine whether or not to incorporate the css in the website assets or not.
<odoo>
<data>
<template id="page_style" name="Page Style" inherit_id="website.assets_frontend">
<xpath expr="link[last()]" position="after">
<t t-if="request.httprequest.path.startswith('/page/path/')">
<link href="/addon_name/path/to/css/style.css" rel="stylesheet" type="text/css"/>
</t>
</xpath>
</template>
</data>
</odoo>
Anyways, if anyone would like to make a suggestion on how they incorporate css into Odoo's frontend assets in a contained way I would appreciate it.
What you can do is actually insert a:
<head>
<link href="/addon_name/path/to/css/style.css" rel="stylesheet" type="text/css"/>
</head>
to your template that you want the specific css/js to be applied to. For a specific example see addons/website_google_map/views/google_map_templates.xml
Your the contents of your head tag will be inserted inside the head tag of the final HTML that will be rendered for that template.
Since it seems to be straighforward and used by the framework itself I have resorted on using it on my own with no problems so far. As I can understand you can also create a javascript Widget that will operate on your template only that will apply a specific css. But the above solution seems cleaner to me.

Flexslider - what am I doing wrong?

I had a really simple question.
I'm trying to implement Flexslider (http://www.woothemes.com/flexslider/) onto my page http://www.gofree.com/123-LAC/ but it does not seem to work (the images appear really large and are listed).
I followed all of the directions on the page. What am I doing wrong?
Thanks in advance!
Use jquery library above the flexslider.
<link rel="stylesheet" href="styles/flexslider.css" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="styles/jquery.flexslider-min.js"></script>
And dont use another jquery library in that page. It create the conflict of both jquery library.
Always Use jquery latest.. It improve the efficiency and performance
of the site
Learn jquery

Apache add Content of a Link to response

I want to know if it is possible to let apache substitue a link in the html I return to the client with the html of the site behind the link.
So instead of
<html>
<head>
</head>
<body>
Link
</body>
</html>
I want something like this:
<html>
<head>
</head>
<body>
// the html of the page behind the link
</body>
</html>
I can´t use javascript or php or anything, let´s assume I only have html.IFrames are as well no solution for my problem.
Just for everyone that comes to a similar situation, Ulrich Schwarz gave a good hint with SSIs, which is in this scenario the only way that could work. However, due to cancelling the project, I was not able to validate the usage of SSI for this scenario.
This can be little painful to do and might not be suitable for all cases but you can maintain a plaintext file for every html page you want to show source of and add a link to that file instead.
For eg: Instead of <a href='somefile.html'>Click</> do <a href='somefile.source'>Click</>
where somefile.source is the copy of the somefile.html. Add triple qoutes """ in the first and the last line of the file. I didn't try a lot of combinations but this works for fairly decent html codes.

Referring to redirect URL in Velocity template

So I'm trying to render a page's URL in the head of the document, for use with rel=canonical. This is on a site running off Velocity templates. The type of content I'm talking about is specifically a quiz -- which has multiple pages, one for each question, not to mention different URL paramters reflecting how many answers the user has gotten correct.
The site has redirect rules in place to generate the URL for the quiz. They look like this:
<rule>
<from>^/([a-zA-Z_0-9\-]*)/(quiz_[a-zA-Z_0-9\-]*)/(\d*).htm$</from>
<to>/contentdata/quiz.htm?path=/$1/$2.xml&qnum=$3</to>
</rule>
All this is by way of explaining that I'm using this Velocity code:
<link rel="canonical" href="$link.self" />
On the template for this page:
http://example.com/fun/quiz_best_quiz_ever/1.htm
Which produces this HTML:
<link rel="canonical" href="/contentdata/quiz.htm" />
But what I want is this HTML:
<link rel="canonical" href="http://example.com/fun/quiz_best_quiz_ever/" />
Is that clear enough? I know this is complicated, but does anyone have any idea as to how I may be able to accomplish it?
Your Velocity template needs to know what the rest of the URL is. You didn't explain how you are rendering the Velocity. Is it Spring? Velocity Servlet? Some other system?
The basic idea is that you need another reference called $baseUrl. Set this in your java code before the Velocity template is merged
(in Java)
context.put("baseUrl", "http://example.com/fun/quiz_best_quiz_ever");
(in Velocity)
<link rel="canonical" href="$baseUrl/$link.self" />

web agent can redirect to the top target?

I'm calling from an iframe an agent that should redirect the user to a given page on the whole page.
It's a lotus script agent that do his stuff and then redirect using a common:
Print "[http://www.server.com/db.nsf/simpleForm?OpenForm]"
How could I mention the TARGET (_top in my case) ?
thanks,
Since no better response had been given, I share my Javascript solution (comment welcome):
Print |<html>
<head>
<script language="JavaScript" type="text/javascript">
<!--
window.top.location.href = "/myDB.nsf/MyFullRedirectedPage?OpenForm&L=|+lang+....+ |";
// -->
</script>
</head>
<body "style=\"margin:0 ; background:transparent\"">
processing... please wait! N.B. this text will appear very short time.
</body>
</html>|
I put a background:transparent since I'm in a iframe.
I don't love this code almost flashing before the whole page is being refreshed.