changing the URL structure of lektor for blog posts to be in the parent directory - lektor

the problem:
we are porting a wordpress blog to lektor. The slugs in wordpress of the post are directly under the main domain e.g. www.mypage.com/my-blogpost-about-food/ not www.mypage.com/blog/my-blogpost-about-food/.
Now the owner is not ready to accept any broken links. Broken links from the outside, e.g. some random internet page links to www.mypage.com/my-blogpost-about-food/. This link will not work in lektor. This will decrease the page rank of the redesign of the page with lektor. What can I do to avoid this?
Again, in our current wordpress website
the main blog page sits under:
www.mypage.com/blog/
each blog post has a unique slug, NOT under /blog/ but directly in the main.
e.g.
www.mypage.com/my-blogpost-about-food/
What can I do, to make these URLs be valid for lektor as well? that e.g. mypage.com/my-blogpost-about-food is a blog post.
EDIT: this is what lektor does not support. Blog posts in lektor must sit in www.mypage.com/blog/SINGLE-BLOG-POSTS-MUSTBEHERE but I want the blog posts to be here www.mypage.com/SINGLE-BLOG-POSTS-MUSTBEHERE
reading here
https://www.getlektor.com/docs/content/urls/
if I go to the system fields and enter my-blogpost-about-food it will still appear in /blog/my-blogpost-about-food/
reading here it becomes clear that I cannot change the slug in the parent model neither:
With the above settings the blog will live at blog/ and the posts at
blog/. But what if you want to put the date of the blog
post into the URL? That's thankfully very easy. All you need to do is
to set up a new URL format for the children. Just edit blog.ini and
add this to the [children] section:
slug_format = {{ (this.pub_date|dateformat('YYYY/M/') if this.pub_date) ~ this._id }}
What this does is that it will prepend the year (YYYY) and month (M)
to the ID of the page if the publication date is configured. Otherwise
it will just use the ID of the page. With this change our blog post
will move from for instance blog/hello/ to blog/2015/12/hello/.
now how would I achieve a behaviour similar to this?
this is the formal of the perma links of our wordpress installation:

This is possible. If you started with the default setup from lektor quickstart:
In models/blog-post.ini, remove hidden = yes
In models/blog.ini, under the pagination section, add items = site.query('/').filter(F._model == 'blog-post')
The first step lets you create blog posts under root in the admin.
The second step tells the page blog to look for its pagination items under /, and only include the ones of type blog-post. This will exclude e.g. About, Blog, etc.
You will now have your site's home page at /, a blog page with list of all posts at /blog, and each post will be located at example.com/my-blogpost-about-food/.
To create a new blog post in the admin, go to the root admin page (not the /blog admin page), click the +, and select Blog Post for your new page type. It will show up in the list on /blog, and live directly under /.

I'm not certain I understand exactly what you want to achieve. If I understand correctly you can possibly solve this using the replaced_with for children functionality:
https://www.getlektor.com/docs/guides/categories/

Related

Facebook comment using ajax/django site

I have just one trouble adding fb comments box in my site. I use kust one url and read the content of the site using js. I put in the head the init of my fb app but I have three post in the main page and I want one comment box for every post. To load the comments of my post I use ((myurl)){{post.id}} to make unique the comment box. This url dosen't exist. But show me up difference comment for every. But don't let me moderate.. I mean dont show the moderation tool. But if i change the href of the post to my url real. Show me the noderstion tool but the same comments in every posts. Any idea???
The page is by ajax bwcause is a radio station and need to listwn the station y all contwnt. There is any way to assign thw url "manualy" in thw api of fb?

How do I modify blog post excerpt from Fishpig?

I'm using Fishpig to pull in blog posts from WordPress and everything is working fine. However, on /blog instead of having the blog posts displayed in their full length I'd like to use excerpts from the posts (similar to WordPress's method of showing posts in archive/category/ect).
I found default.phtml under app/design/frontend/base/default/template/wordpress/post/list/renderer/default.phtml and see that on line 21 is <?php echo $post->getPostExcerpt() ?>
When commenting this out the content from the posts on /blog no longer shows, indicating I'm in the right file. I really wish I could just use get_excerpt(); here. How/what do I modify to pull in an excerpt instead so the blog pages listing posts don't just pull in the entirety of each post?
To show an excerpt, you have 3 different options:
1) Go to your post in the WordPress Admin and manually enter a post excerpt in the post excerpt field. This field is located just below the post content field. If this isn't visible, click the 'Screen Options' tab at the top of the page and enable the post excerpt field.
2) Go to your post in the WordPress Admin and use the More tag/button to split the post. Every thing before the More tag will be used as the post excerpt. You can find out more about the More tag at the following URL:
http://en.support.wordpress.com/splitting-content/more-tag/
3) Open the list template (wordpress/post/list/renderer/default.phtml) and add some PHP code to shorten the post content.
Copy the default.phtml file from /base/default/template/wordpress/post/list/renderer/ in to your theme with same folder structure. Then comment the lines that cause for post description and add below code.
$content = $post->getPostExcerpt();
$content = strip_tags($content);
echo substr($content, 0, 250);

Magento Anchor Tags

I have a list of FAQ links on my home page in a static block in the footer. Each link however just opens up the FAQ page.
My code sample
What is Individually Quick Frozen?</li>
What I want is that when a user clicks a particular link in the list on the homepage footer under FAQs (as above), the user should be directly be taken to the answer of that question on the FAQ page i.e. the page should scroll down to where the questions is answered.
My Code sample
<p><strong><a id="1">What is Individually Quick Frozen?</a></strong></p>
But no joy! what am I doing wrong?
Make your link look like this:
What is Individually Quick Frozen?</li>
or better yet
What is Individually Quick Frozen?</li>
Note: For Cms pages urls use direct_url as a parameter for the {{store}} directive. It avoids having a / at the end of the URL. Useful if your pages end with .html. It's not your case but it may be useful in the future.
Now your code in the cms page should looks like this:
<p><strong><a id="_1">What is Individually Quick Frozen?</a></strong></p>
Avoid using numerical ids for elements. It's not standard
Worked perfectly, be sure to update
<a href="{{store url="faqs"}}#_1">
"faqs" to what ever page you want your tag to land on though.

Wordpress Filter by Tag with Ajax

I'm setting up a P2 themed (using Houston child theme) Wordpress. I want to accomplish the following but after hours and hours of searching I cannot figure out how to do this even though it seems like something that would be common.
Ideally, I would like a tag list in the sidebar with checkboxes for each tag. Only posts that match checked tags are displayed and it updates with Ajax rather than a page reload. It saves what you have checked to the user profile (page will require login).
I would settle for simply having a tag list/cloud that would update with Ajax if I could also have links that would display multiple tags. It's no problem if I have to hard code these tag-grouping links.
Basically I want users to control what posts they are interested in reading, the assumption is no one will be reading every post, just the tags that pertain to them.
The best I was able to find was this plugin:
Cat + Tag Filter
http://wordpress.org/extend/plugins/cat-tag-filter-widget/
And configuring it for checkboxes on tag. It doesn't reload with Ajax or remember what the user selected, but it does take you to a tag filtered page that you could bookmark.

Retrieve the content of a section via MediaWiki API

I have a MediaWiki page set up in my company's intranet.
I would like to get the content of a section in a specific page using MediaWiki API (through AJAX).
I would like to refer to the section by its title like 'General' and refer to the page by its title as well, like 'Licenses'.
Is it possible somehow?
The only thing I could achieve is referring to the page by its title and refer to the section by a number like this:
http://mywiki.local/wiki/api.php?format=xml&action=parse&prop=text&page=Licenses&section=1
But let's say I create a new section before 'General' I would have to update all my AJAX URLs that queries this page. So this isn't good enough.
I couldn't find any working solution for this. Any ideas?
You can do this by first retrieving prop=sections to get the list of sections and their numbers:
http://en.wikipedia.org/w/api.php?format=xml&action=parse&prop=sections&page=License
Then make your original request, with the section number you figured out based on the previous request.
Keep in mind that two different sections can have the same name.

Resources