Search Results

Search found 134 results on 6 pages for 'permalink'.

Page 3/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • Django manager for _set in model

    - by Daniel Johansson
    Hello, I'm in the progress of learning Django at the moment but I can't figure out how to solve this problem on my own. I'm reading the book Developers Library - Python Web Development With Django and in one chapter you build a simple CMS system with two models (Story and Category), some generic and custom views together with templates for the views. The book only contains code for listing stories, story details and search. I wanted to expand on that and build a page with nested lists for categories and stories. - Category1 -- Story1 -- Story2 - Category2 - Story3 etc. I managed to figure out how to add my own generic object_list view for the category listing. My problem is that the Story model have STATUS_CHOICES if the Story is public or not and a custom manager that'll only fetch the public Stories per default. I can't figure out how to tell my generic Category list view to also use a custom manager and only fetch the public Stories. Everything works except that small problem. I'm able to create a list for all categories with a sub list for all stories in that category on a single page, the only problem is that the list contains non public Stories. I don't know if I'm on the right track here. My urls.py contains a generic view that fetches all Category objects and in my template I'm using the *category.story_set.all* to get all Story objects for that category, wich I then loop over. I think it would be possible to add a if statement in the template and use the VIEWABLE_STATUS from my model file to check if it should be listed or not. The problem with that solution is that it's not very DRY compatible. Is it possible to add some kind of manager for the Category model too that only will fetch in public Story objects when using the story_set on a category? Or is this the wrong way to attack my problem? Related code urls.py (only category list view): urlpatterns += patterns('django.views.generic.list_detail', url(r'^categories/$', 'object_list', {'queryset': Category.objects.all(), 'template_object_name': 'category' }, name='cms-categories'), models.py: from markdown import markdown import datetime from django.db import models from django.db.models import permalink from django.contrib.auth.models import User VIEWABLE_STATUS = [3, 4] class ViewableManager(models.Manager): def get_query_set(self): default_queryset = super(ViewableManager, self).get_query_set() return default_queryset.filter(status__in=VIEWABLE_STATUS) class Category(models.Model): """A content category""" label = models.CharField(blank=True, max_length=50) slug = models.SlugField() class Meta: verbose_name_plural = "categories" def __unicode__(self): return self.label @permalink def get_absolute_url(self): return ('cms-category', (), {'slug': self.slug}) class Story(models.Model): """A hunk of content for our site, generally corresponding to a page""" STATUS_CHOICES = ( (1, "Needs Edit"), (2, "Needs Approval"), (3, "Published"), (4, "Archived"), ) title = models.CharField(max_length=100) slug = models.SlugField() category = models.ForeignKey(Category) markdown_content = models.TextField() html_content = models.TextField(editable=False) owner = models.ForeignKey(User) status = models.IntegerField(choices=STATUS_CHOICES, default=1) created = models.DateTimeField(default=datetime.datetime.now) modified = models.DateTimeField(default=datetime.datetime.now) class Meta: ordering = ['modified'] verbose_name_plural = "stories" def __unicode__(self): return self.title @permalink def get_absolute_url(self): return ("cms-story", (), {'slug': self.slug}) def save(self): self.html_content = markdown(self.markdown_content) self.modified = datetime.datetime.now() super(Story, self).save() admin_objects = models.Manager() objects = ViewableManager() category_list.html (related template): {% extends "cms/base.html" %} {% block content %} <h1>Categories</h1> {% if category_list %} <ul id="category-list"> {% for category in category_list %} <li><a href="{{ category.get_absolute_url }}">{{ category.label }}</a></li> {% if category.story_set %} <ul> {% for story in category.story_set.all %} <li><a href="{{ story.get_absolute_url }}">{{ story.title }}</a></li> {% endfor %} </ul> {% endif %} {% endfor %} </ul> {% else %} <p> Sorry, no categories at the moment. </p> {% endif %} {% endblock %}

    Read the article

  • Running in to some issues with Tumblr's Theme Parser

    - by Kylee
    Below part of a tumblr theme I'm working on and you will notice that I use the {block:PostType} syntax to declare the opening tag of each post, which is a <li> element in an Ordered List. This allows me to not only dynamicly set the li's class based on the type of post but cuts down on the number of times I'm calling the ShareThis JS which was really bogging down the page. This creates a new issue though which I believe is a flaw in Tumblr's parser. Each post is an ordered list with one <li> element in it. I know I could solve this by having each post as a <div> but I really like the control and semantics of using a list. Tumblr gurus? Suggestions? Sample of code: {block:Posts} <ol class="posts"> {block:Text} <li class="post type_text" id="{PostID}"> {block:Title} <h2><a href="{Permalink}" title="Go to post '{Title}'.">{Title}</a></h2> {/block:Title} {Body} {/block:Text} {block:Photo} <li class="post type_photo" id="{PostID}"> <div class="image"> <a href="{LinkURL}"><img src="{PhotoURL-500}" alt="{PhotoAlt}"></a> </div> {block:Caption} {Caption} {/block:Caption} {/block:Photo} {block:Photoset} <li class="post type_photoset" id="{PostID}"> {Photoset-500} {block:Caption} {Caption} {/block:Caption} {/block:Photoset} {block:Quote} <li class="post type_quote" id="{PostID}"> <blockquote> <div class="quote_symbol">&ldquo;</div> {Quote} </blockquote> {block:Source} <div class="quote_source">{Source}</div> {/block:Source} {/block:Quote} {block:Link} <li class="post type_link" id="{PostID}"> <h2><a href="{URL}" {Target} title="Go to {Name}.">{Name}</a></h2> {block:Description} {Description} {/block:Description} {/block:Link} {block:Chat} <li class="post type_chat" id="{PostID}"> {block:Title} <h2><a href="{Permalink}" title="Go to post {PostID} '{Title}'.">{Title}</a></h2> {/block:Title} <table class="chat_log"> {block:Lines} <tr class="{Alt} user_{UserNumber}"> <td class="person">{block:Label}{Label}{/block:Label}</td> <td class="message">{Line}</td> </tr> {/block:Lines} </table> {/block:Chat} {block:Video} <li class="post type_video" id="{PostID}"> {Video-500} {block:Caption} {Caption} {/block:Caption} {/block:Video} {block:Audio} <li class="post type_audio" id="{PostID}"> {AudioPlayerWhite} {block:Caption} {Caption} {/block:Caption} {block:ExternalAudio} <p><a href="{ExternalAudioURL}" title="Download '{ExternalAudioURL}'">Download</a></p> {/block:ExternalAudio} {/block:Audio} <div class="post_footer"> <p class="post_date">Posted on {ShortMonth} {DayOfMonth}, {Year} at {12hour}:{Minutes} {AmPm}</p> <ul> <li><a class="comment_link" href="{Permalink}#disqus_thread">Comments</a></li> <li><script type="text/javascript" src="http://w.sharethis.com/button/sharethis.js#publisher=722e181d-1d8a-4363-9ebe-82d5263aea94&amp;type=website"></script></li> </ul> {block:PermalinkPage} <div id="disqus_thread"></div> <script type="text/javascript" src="http://disqus.com/forums/kyleetilley/embed.js"></script> <noscript><a href="http://disqus.com/forums/kyleetilley/?url=ref">View the discussion thread.</a></noscript> {/block:PermalinkPage} </div> </li> </ol> {/block:Posts}

    Read the article

  • Wordpress SQL Select Multiple Meta Values / Meta Keys / Custom Fields

    - by Wes
    I am trying to modify a wordpress / MySQL function to display a little more information. I'm currently running the following query that selects the post, joins the 'postmeta' and gets the info where the meta_key = _liked function most_liked_posts($numberOf, $before, $after, $show_count) { global $wpdb; $request = "SELECT ID, post_title, meta_value FROM $wpdb->posts, $wpdb->postmeta"; $request .= " WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id"; $request .= " AND post_status='publish' AND post_type='post' AND meta_key='_liked' "; $request .= " ORDER BY $wpdb->postmeta.meta_value+0 DESC LIMIT $numberOf"; $posts = $wpdb->get_results($request); foreach ($posts as $post) { $post_title = stripslashes($post->post_title); $permalink = get_permalink($post->ID); $post_count = $post->meta_value; echo $before.'<a href="' . $permalink . '" title="' . $post_title.'" rel="nofollow">' . $post_title . '</a>'; echo $show_count == '1' ? ' ('.$post_count.')' : ''; echo $after; } } The important part being: $post_count = $post->meta_value; But now I want to also grab a value that is attached to each post called wbphoto How do I specify that $post_count = _liked and $photo = wbphoto ? Here is a screen cap of my Phpmyadmin

    Read the article

  • Help with understanding generic relations in Django (and usage in Admin)

    - by saturdayplace
    I'm building a CMS for my company's website (I've looked at the existing Django solutions and want something that's much slimmer/simpler, and that handles our situation specifically.. Plus, I'd like to learn this stuff better). I'm having trouble wrapping my head around generic relations. I have a Page model, a SoftwareModule model, and some other models that define content on our website, each with their get_absolute_url() defined. I'd like for my users to be able to assign any Page instance a list of objects, of any type, including other page instances. This list will become that Page instance's sub-menu. I've tried the following: class Page(models.Model): body = models.TextField() links = generic.GenericRelation("LinkedItem") @models.permalink def get_absolute_url(self): # returns the right URL class LinkedItem(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey('content_type', 'object_id') title = models.CharField(max_length=100) def __unicode__(self): return self.title class SoftwareModule(models.Model): name = models.CharField(max_length=100) description = models.TextField() def __unicode__(self): return self.name @models.permalink def get_absolute_url(self): # returns the right URL This gets me a generic relation with an API to do page_instance.links.all(). We're on our way. What I'm not sure how to pull off, is on the page instance's change form, how to create the relationship between that page, and any other extant object in the database. My desired end result: to render the following in a template: <ul> {% for link in page.links.all %} <li><a href='{{ link.content_object.get_absolute_url() }}'>{{ link.title }}</a></li> {% endfor%} </ul> Obviously, there's something I'm unaware of or mis-understanding, but I feel like I'm, treading into that area where I don't know what I don't know. What am I missing?

    Read the article

  • WordPress Get 1 attachment per post from X category outside the loop

    - by davebowker
    Hey, Hope someone can help with this. What I want is to display 5 attachments but only 1 attachment from each post from a specific category in the sidebar, which links to the posts permalink. I'm using the following code so far which gets all attachments from all posts, but some posts have more than 1 attachment and I just want to show the first one, and link it to the permalink of the post. So although the limit is 5 posts, if one post has 4 attachments then currently it will show 4 from one, and 1 from the other totalling 5, when what I want it to do is just show 1 from each of 5 different posts. <?php $args = array( 'post_type' => 'attachment', 'numberposts' => 5, 'post_status' => null, 'post_parent' => null, // any parent 'category_name' => 'work', ); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $post) { setup_postdata($post); the_title(); the_permalink(); the_attachment_link($post->ID, false); the_excerpt(); } } ?> Cheers. Dave

    Read the article

  • Ruby and RSS2 Feed not displaying image

    - by pcasa
    Trying to create a simple RSS2 Feed that I could later pass on to FeedBurner but can't get RSS feed to display images at all. Also, from what I have read having xml.instruct! on top might cause IE to complain it's not a valid feed. Is this true? My Code looks like xml.instruct! xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do xml.channel do xml.title "Store" xml.link url_for :only_path => false, :controller => 'products' xml.description "Store" xml.pubDate @products.first.updated_at.rfc822 if @products.any? @products.each do |product| xml.item do xml.title product.name xml.pubDate (product.updated_at.rfc822) xml.image do xml.url domain_host + product.product_image.url(:small) xml.title "Store" xml.link url_for :only_path => false, :controller => 'products' end xml.link url_for :only_path => false, :controller => 'products', :action => 'show', :id => product.permalink xml.description product.fine_print xml.guid url_for :only_path => false, :controller => 'products', :action => 'show', :id => product.permalink end end end end

    Read the article

  • Generating URLs when not using an integer as an id?

    - by Synthesezia
    So I'm building a blog engine which has /articles/then-the-article-permalink as it's URL structure. I need to have prev and next links which will jump to the next article by pub_date, my code looks like this: In my articles#show @article = Article.find_by_permalink(params[:id]) @prev_article = Article.find(:first, :conditions => [ "pub_date < ?", @article.pub_date]) @next_picture = Article.find(:first, :conditions => [ "pub_date > ?", @article.pub_date]) And in my show.html.erb <%= link_to "Next", article_path(@next_article) %> <%= link_to 'Prev', article_path(@prev_article) %> In my articles model I have this: def to_param self.permalink end The specific error message I get is: article_url failed to generate from {:action=>"show", :controller=>"articles", :id=>nil}, expected: {:action=>"show", :controller=>"articles"}, diff: {:id=>nil} Without the prev and next everything is working fine but I'm out of ideas as to why this isn't working. Anyone want to helo?

    Read the article

  • Paging not working in my wordpress installation

    - by Bootcamp
    I recently started a blog site and wanted to give it a magazine look. I used Wordpress for my blog and used the Arthemia theme with it. I also changed the permalink structure to point to /%year%/%monthnum%/%day%/%postname%/ structure. Now the problem that i have is that the paging has stopped working on my home page. When i click on the next page link i get a 404 error. My /page/2 url does not show the next page. I check on google and found out that it was due to the redirection that is being performed due to the permalink change. The solution given was that i need to skip the url rewriting for the /page/* urls. This is the link to an article which said this http://www.yoursearchadvisor.com/blog/wordpress-next_posts_link-broken/ . I was not able to follow this article and solve my problem, as i could not find the permanent redirect manager under the settings section as said in this article. Can somebody please guide me how to solve this problem. I am using the latest Wordpress version and Arthemia theme with it. Thanks.

    Read the article

  • How to take html markup from a string and escape it to work within a script?

    - by zac
    I am using wordpress as a CMS and trying to allow user fields to be input to populate the info windows in a Google Map script. I am using this to select the id and pull in the content from a custom field : $post_id = 222; $my_post = get_post($post_id); $snip = get_post_meta($post_id, 'custom-field', true); $permalink = get_permalink( $post_id ); $pass_to = '<div class="content">'.$snip.'</div><div class="moreLink"><a href="'.$permalink.'">Find out more » </a></div></div>'; var point = new GLatLng('<?php echo $lat; $lat; ?>','<?php echo $long; $long; ?>'); var marker = createMarker(point,"<?php echo $mapTitle; $mapTitle; ?>", '<?php echo $pass_to; ?>') map.addOverlay(marker); It works fine unless there is any html in the custom-field which breaks the script. I looked at htmlspcialchar and htmlentities but rather than strip everything out I would like to have it escaped so it still works and the html is intact. Any suggestions? I am pretty new to PHP and would really appreciate any pointers.

    Read the article

  • PHP issue json_decode echo array

    - by dfdf
    <?php $string = file_get_contents("http://www.reddit.com/r/news.json"); $array = json_decode($string, true); echo $array['data'][0]['children'][0]['data'][0]['title'][0]; ?> I've got a problem- the code doesn't echo anything. I'm kinda new to json_decode, so any help is appreciated :-) Edit: As a response to a comment, here's what print_r results to: Array ( [kind] => Listing [data] => Array ( [modhash] => [children] => Array ( [0] => Array ( [kind] => t3 [data] => Array ( [domain] => syracuse.com [banned_by] => [media_embed] => Array ( ) [subreddit] => news [selftext_html] => [selftext] => [likes] => [secure_media] => [link_flair_text] => [id] => 1qdtqr [secure_media_embed] => Array ( ) [clicked] => [stickied] => [author] => cadencehz [media] => [score] => 1552 [approved_by] => [over_18] => [hidden] => [thumbnail] => [subreddit_id] => t5_2qh3l [edited] => [link_flair_css_class] => [author_flair_css_class] => [downs] => 978 [saved] => [is_self] => [permalink] => /r/news/comments/1qdtqr/thousands_defend_grocery_store_employee_with/ [name] => t3_1qdtqr [created] => 1384215998 [url] => http://www.syracuse.com/news/index.ssf/2013/11/thousands_come_to_defense_of_clay_wegmans_employee_with_aspergers_syndrome_after.html#incart_m-rpt-2 [author_flair_text] => [title] => Thousands defend grocery store employee with Asperger's syndrome after customer yells at him for being too slow [created_utc] => 1384187198 [ups] => 2530 [num_comments] => 401 [visited] => [num_reports] => [distinguished] => ) ) [1] => Array ( [kind] => t3 [data] => Array ( [domain] => bostonherald.com [banned_by] => [media_embed] => Array ( ) [subreddit] => news [selftext_html] => [selftext] => [likes] => [secure_media] => [link_flair_text] => [id] => 1qddl6 [secure_media_embed] => Array ( ) [clicked] => [stickied] => [author] => boxofrain [media] => [score] => 2086 [approved_by] => [over_18] => [hidden] => [thumbnail] => [subreddit_id] => t5_2qh3l [edited] => [link_flair_css_class] => [author_flair_css_class] => [downs] => 2556 [saved] => [is_self] => [permalink] => /r/news/comments/1qddl6/motorcycle_stolen_in_1961_found_is_recovered_and/ [name] => t3_1qddl6 [created] => 1384199801 [url] => http://bostonherald.com/news_opinion/offbeat_news/2013/11/man_glad_stolen_motorcycle_found_after_46_years [author_flair_text] => [title] => Motorcycle stolen in 1961 found is recovered and will be returned to it 73 year old owner. [created_utc] => 1384171001 [ups] => 4642 [num_comments] => 141 [visited] => [num_reports] => [distinguished] => ) ) [2] => Array ( [kind] => t3 [data] => Array ( [domain] => hosted.ap.org [banned_by] => [media_embed] => Array ( ) [subreddit] => news [selftext_html] => [selftext] => [likes] => [secure_media] => [link_flair_text] => [id] => 1qe6gp [secure_media_embed] => Array ( ) [clicked] => [stickied] => [author] => donkey-kick [media] => [score] => 415 [approved_by] => [over_18] => [hidden] => [thumbnail] => [subreddit_id] => t5_2qh3l [edited] => [link_flair_css_class] => [author_flair_css_class] => [downs] => 334 [saved] => [is_self] => [permalink] => /r/news/comments/1qe6gp/atheist_mega_churches_take_hold_in_the_us_and/ [name] => t3_1qe6gp [created] => 1384224670 [url] => http://hosted.ap.org/dynamic/stories/U/US_ATHEIST_MEGACHURCH?SITE=AP&amp;SECTION=HOME&amp;TEMPLATE=DEFAULT&amp;CTIME=2013-11-10-17-03-15 [author_flair_text] => [title] => Atheist Mega Churches take hold in the US and around the world. [created_utc] => 1384195870 [ups] => 749 [num_comments] => 368 [visited] => [num_reports] => [distinguished] => ) ) [3] => Array ( [kind] => t3 [data] => Array ( [domain] => abcnews.go.com [banned_by] => [media_embed] => Array ( ) [subreddit] => news [selftext_html] => [selftext] => [likes] => [secure_media] => [link_flair_text] => [id] => 1qdie4 [secure_media_embed] => Array ( ) [clicked] => [stickied] => [author] => Hoosier_made [media] => [score] => 984 [approved_by] => [over_18] => [hidden] => [thumbnail] => [subreddit_id] => t5_2qh3l [edited] => [link_flair_css_class] => [author_flair_css_class] => [downs] => 400 [saved] => [is_self] => [permalink] => /r/news/comments/1qdie4/abc_news_amy_robach_has_mammogram_live_on_gma/ [name] => t3_1qdie4 [created] => 1384206209 [url] => http://abcnews.go.com/blogs/health/2013/11/11/abc-news-amy-robach-reveals-breast-cancer-diagnosis/ [author_flair_text] => [title] => ABC News’ Amy Robach has mammogram live on GMA. Results Reveal Breast Cancer Diagnosis. [created_utc] => 1384177409 [ups] => 1384 [num_comments] => 130 [visited] => [num_reports] => [distinguished] => ) ) // ECT... I CUT HERE BECAUSE IT WENT ON FOR A WHILE [after] => t3_1qdinr [before] => ) ) Here's the url to the exact output, I had to trim the code to fit the character limit so maybe there's something I messed up ! :P Okay: Link goes here...

    Read the article

  • WordPress 3.5 Multisite and nginx siteurl issues

    - by Florin Gogianu
    I'm setting up multisite on localhost in subdirectories. The problem is that when I'm trying to access the dashboard of a site I just created ( localhost/wptest/site/wp-admin ) I get "This webpage has a redirect loop" and when I try to access the actual website ( localhost/wptest/site ) the page loads but without assets, such as css. When I access the network dashboard, or the primary site dashboard on localhost/wptest everything is just fine. Also when I edit the permalink of the second site in the network dashboard, to be like this: localhost/site it also runs fine. How to make it work with the default permalink structure localhost/wptest/site? The wordpress files are in /usr/share/html/wptest The wp-config.php is as follows: define('WP_ALLOW_MULTISITE', true); define('MULTISITE', true); define('SUBDOMAIN_INSTALL', false); define('DOMAIN_CURRENT_SITE', 'localhost'); define('PATH_CURRENT_SITE', '/wptest/'); define('SITE_ID_CURRENT_SITE', 1); define('BLOG_ID_CURRENT_SITE', 1); And the server block / virtual host is like this: server { ##DM - uncomment following line for domain mapping listen 80 default_server; #server_name example.com *.example.com ; ##DM - uncomment following line for domain mapping #server_name_in_redirect off; access_log /var/log/nginx/example.com.access.log; error_log /var/log/nginx/example.com.error.log; root /usr/share/nginx/html/wptest; index index.html index.htm index.php; if (!-e $request_filename) { rewrite /wp-admin$ $scheme://$host$uri/ permanent; rewrite ^(/[^/]+)?(/wp-.*) $2 last; rewrite ^(/[^/]+)?(/.*\.php) $2 last; } location / { try_files $uri $uri/ /index.php?$args ; } location ~ \.php$ { try_files $uri /index.php; include fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock; } location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { access_log off; log_not_found off; expires max; } location = /robots.txt { access_log off; log_not_found off; } location ~ /\. { deny all; access_log off; log_not_found off; } } And finally here's an error log: 2013/06/29 08:05:37 [error] 4056#0: *52 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 127.0.0.1, server: example.com, request: "GET /nginx HTTP/1.1", host: "localhost"

    Read the article

  • Open XML SDK 2 Released

    - by Tim Murphy
    Note: Cross posted from Coding The Document. Permalink This post is a little late since the SDK was released about a week ago.  At PSC we have been using the Open XML SDK 2 since its earliest beta.  It is a very powerful tool for generating documents without using the Office DLLs.  It is also the main technology that I have been working with for the last six months.  I would suggest giving it a try.  Stay tuned here.  In the near future I will be presenting at different locations on this and other document generation technologies. Download the Open XML SDK here. del.icio.us Tags: Office Open XML,Open XML SDK 2

    Read the article

  • Handbrake-powered VidCoder gets a native 64-bit version

    A while back, VidCoder -- the Windows video disc ripping program -- added support for Blu-ray discs. With Handbrake's engine under the hood, VidCoder offers an easy-to-use interface and simple batch processing of your video files. With the release of version 0.8, there's also now a native 64-bit version for those of you running Windows x64. A number of stability tweaks have also been introduced. As Baz pointed out in our comments last time, VidCoder is particular useful on netbooks. If you've got a 1024x600 screen, Handbrake may not even launch for you -- but VidCoder will fire up just fine. Take the new 64-bit version for a spin, and share your thoughts in the comments. Download VidCoderHandbrake-powered VidCoder gets a native 64-bit version originally appeared on Download Squad on Fri, 07 Jan 2011 17:00:00 EST. Please see our terms for use of feeds.Permalink | Email this | Comments

    Read the article

  • Does having multiple URIs mapping to the same resource help SEO?

    - by Brian Wheeler
    Let's say I have a site with products that have tags, if each resource is available at GET '/products/tagged/:tag_list/:product_permalink' Could that be better for SEO than just one permalink? For example a product tagged "tea" and "coffee" would be available at GET '/products/tagged/tea/:product_permalink' GET '/products/tagged/coffee/:product_permalink' GET '/products/tagged/tea/coffee/:product_permalink' GET '/products/tagged/coffee/tea/:product_permalink' I would imagine that google would appreciate this because it gives multiple URIs with different levels of detail about the product, but I cant really be certain. Anyone have any direct knowledge on the topic? --EDIT-- As John Conde points, this is a horrible idea. What about having the links on my site link to a route such as GET '/products/tagged/:full_tag_list/:product_permalink', and then any time a user changes tags just have a HTTP moved permanently status to the new URL. Therefore duplicate URLs would be highly unlikely and mitigated by the proper response. Would this be better?

    Read the article

  • What is a good robots.txt for WP ?

    - by Steven
    What is the "best" setup for robots.txt? I'm using the following permalink structure in Wordpress: /%category%/%postname%/. My robots.txt currently looks like this (copied from somewhere a long time ago): User-agent: * Disallow: /cgi-bin Disallow: /wp-admin Disallow: /wp-includes Disallow: /wp-content/plugins Disallow: /wp-content/cache Disallow: /wp-content/themes Disallow: /trackback Disallow: /comments Disallow: /category/*/* Disallow: */trackback Disallow: */comments I want my comments to be indext. So I can remove this, right? Do I want to disallow indexing categories because of my permalinkstructure? An article can have several tags and be in multiple categories. This may cause duplicates in google. How should I work around this? Would you change anything else here?

    Read the article

  • How to make content display on their proper pages on search engines

    - by Dendory
    So my site has a blog and gallery, both working the same way. There's an index, and each post has a permalink going to the individual entry. However, if I search for some of the content on Google, often it returns a link to the index, just because it happened to have been on the first page when it was crawled, instead of the individual post pages. This is especially true in cases of images. How can I make it so that Google returns the proper pages for the posts instead of just the main page of my site? My whole site is custom php code I made.

    Read the article

  • Personal Activity Monitor tracks time you spend using desktop apps

    Up until a couple of years ago, I used to turn to RescueTime to figure out how I spend my time online. Then it got too complex, and I stopped using it. Personal Activity Monitor is like a vastly dumbed-down version of RescueTime, and I mean that as a compliment. It's free and bare-bones -- all it does is track what applications you're using and for how long. A big drawback at this point is that it doesn't integrate with Web browsers to help you analyze how you spend your time on the Web. Still, if your work doesn't require constant Web app use, knowing how long you've used a browser overall might be enough to help you manage your time. This is far from the only application in this space -- alternatives such as Slife and Chrometa are full-featured and impressive -- but PAM is good option for those who want a nice, simple tracker.Personal Activity Monitor tracks time you spend using desktop apps originally appeared on Download Squad on Sat, 05 Mar 2011 10:00:00 EST. Please see our terms for use of feeds.Permalink | Email this | Comments

    Read the article

  • Testing Django Inline ModelForms: How to arrange POST data?

    - by unclaimedbaggage
    Hi folks, I have a Django 'add business' view which adds a new business with an inline 'business_contact' form. The form works fine, but I'm wondering how to write up the unit test - specifically, the 'postdata' to send to self.client.post(settings.BUSINESS_ADD_URL, postdata) I've inspected the fields in my browser and tried adding post data with corresponding names, but I still get a 'ManagementForm data is missing or has been tampered with' error when run. Anyone know of any resources for figuring out how to post inline data? Relevant models, views & forms below if it helps. Lotsa thanks. MODEL: class Contact(models.Model): """ Contact details for the representatives of each business """ first_name = models.CharField(max_length=200) surname = models.CharField(max_length=200) business = models.ForeignKey('Business') slug = models.SlugField(max_length=150, unique=True, help_text=settings.SLUG_HELPER_TEXT) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) phone = models.CharField(max_length=100, null=True, blank=True) mobile_phone = models.CharField(max_length=100, null=True, blank=True) email = models.EmailField(null=True) deleted = models.BooleanField(default=False) class Meta: db_table='business_contact' def __unicode__(self): return '%s %s' % (self.first_name, self.surname) @models.permalink def get_absolute_url(self): return('business_contact', (), {'contact_slug': self.slug }) class Business(models.Model): """ The business clients who you are selling products/services to """ business = models.CharField(max_length=255, unique=True) slug = models.SlugField(max_length=100, unique=True, help_text=settings.SLUG_HELPER_TEXT) description = models.TextField(null=True, blank=True) primary_contact = models.ForeignKey('Contact', null=True, blank=True, related_name='primary_contact') business_type = models.ForeignKey('BusinessType') deleted = models.BooleanField(default=False) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) address_1 = models.CharField(max_length=255, null=True, blank=True) address_2 = models.CharField(max_length=255, null=True, blank=True) suburb = models.CharField(max_length=255, null=True, blank=True) city = models.CharField(max_length=255, null=True, blank=True) state = models.CharField(max_length=255, null=True, blank=True) country = models.CharField(max_length=255, null=True, blank=True) phone = models.CharField(max_length=40, null=True, blank=True) website = models.URLField(null=True, blank=True) class Meta: db_table = 'business' def __unicode__(self): return self.business def get_absolute_url(self): return '%s%s/' % (settings.BUSINESS_URL, self.slug) VIEWS: class Contact(models.Model): """ Contact details for the representatives of each business """ first_name = models.CharField(max_length=200) surname = models.CharField(max_length=200) business = models.ForeignKey('Business') slug = models.SlugField(max_length=150, unique=True, help_text=settings.SLUG_HELPER_TEXT) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) phone = models.CharField(max_length=100, null=True, blank=True) mobile_phone = models.CharField(max_length=100, null=True, blank=True) email = models.EmailField(null=True) deleted = models.BooleanField(default=False) class Meta: db_table='business_contact' def __unicode__(self): return '%s %s' % (self.first_name, self.surname) @models.permalink def get_absolute_url(self): return('business_contact', (), {'contact_slug': self.slug }) class Business(models.Model): """ The business clients who you are selling products/services to """ business = models.CharField(max_length=255, unique=True) slug = models.SlugField(max_length=100, unique=True, help_text=settings.SLUG_HELPER_TEXT) description = models.TextField(null=True, blank=True) primary_contact = models.ForeignKey('Contact', null=True, blank=True, related_name='primary_contact') business_type = models.ForeignKey('BusinessType') deleted = models.BooleanField(default=False) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) address_1 = models.CharField(max_length=255, null=True, blank=True) address_2 = models.CharField(max_length=255, null=True, blank=True) suburb = models.CharField(max_length=255, null=True, blank=True) city = models.CharField(max_length=255, null=True, blank=True) state = models.CharField(max_length=255, null=True, blank=True) country = models.CharField(max_length=255, null=True, blank=True) phone = models.CharField(max_length=40, null=True, blank=True) website = models.URLField(null=True, blank=True) class Meta: db_table = 'business' def __unicode__(self): return self.business def get_absolute_url(self): return '%s%s/' % (settings.BUSINESS_URL, self.slug) FORMS: class AddBusinessForm(ModelForm): class Meta: model = Business exclude = ['deleted','primary_contact',] class ContactForm(ModelForm): class Meta: model = Contact exclude = ['deleted',] AddBusinessFormSet = inlineformset_factory(Business, Contact, can_delete=False, extra=1, form=AddBusinessForm, )

    Read the article

  • ContentType Issue -- Human is an idiot - Can't figure out how to tie the original model to a Content

    - by bmelton
    Originally started here: http://stackoverflow.com/questions/2650181/django-in-query-as-a-string-result-invalid-literal-for-int-with-base-10 I have a number of apps within my site, currently working with a simple "Blog" app. I have developed a 'Favorite' app, easily enough, that leverages the ContentType framework in Django to allow me to have a 'favorite' of any type... trying to go the other way, however, I don't know what I'm doing, and can't find any examples for. I'll start off with the favorite model: favorite/models.py from django.db import models from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic from django.contrib.auth.models import User class Favorite(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() user = models.ForeignKey(User) content_object = generic.GenericForeignKey() class Admin: list_display = ('key', 'id', 'user') class Meta: unique_together = ("content_type", "object_id", "user") Now, that allows me to loop through the favorites (on a user's "favorites" page, for example) and get the associated blog objects via {{ favorite.content_object.title }}. What I want now, and can't figure out, is what I need to do to the blog model to allow me to have some tether to the favorite (so when it is displayed in a list it can be highlighted, for example). Here is the blog model: blog/models.py from django.db import models from django.db.models import permalink from django.template.defaultfilters import slugify from category.models import Category from section.models import Section from favorite.models import Favorite from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic class Blog(models.Model): title = models.CharField(max_length=200, unique=True) slug = models.SlugField(max_length=140, editable=False) author = models.ForeignKey(User) homepage = models.URLField() feed = models.URLField() description = models.TextField() page_views = models.IntegerField(null=True, blank=True, default=0 ) created_on = models.DateTimeField(auto_now_add = True) updated_on = models.DateTimeField(auto_now = True) def __unicode__(self): return self.title @models.permalink def get_absolute_url(self): return ('blog.views.show', [str(self.slug)]) def save(self, *args, **kwargs): if not self.slug: slug = slugify(self.title) duplicate_count = Blog.objects.filter(slug__startswith = slug).count() if duplicate_count: slug = slug + str(duplicate_count) self.slug = slug super(Blog, self).save(*args, **kwargs) class Entry(models.Model): blog = models.ForeignKey('Blog') title = models.CharField(max_length=200) slug = models.SlugField(max_length=140, editable=False) description = models.TextField() url = models.URLField(unique=True) image = models.URLField(blank=True, null=True) created_on = models.DateTimeField(auto_now_add = True) def __unicode__(self): return self.title def save(self, *args, **kwargs): if not self.slug: slug = slugify(self.title) duplicate_count = Entry.objects.filter(slug__startswith = slug).count() if duplicate_count: slug = slug + str(duplicate_count) self.slug = slug super(Entry, self).save(*args, **kwargs) class Meta: verbose_name = "Entry" verbose_name_plural = "Entries" Any guidance?

    Read the article

  • Scala command line parameters in eclipse?

    - by Mitch Blevins
    Scala includes the continuations plugin now (yay), but must be enabled by passing "-P:continuations:enable" to the scala compiler. Is there a way to pass arbitrary arguments to scalac for the eclipse scala plugin? From: http://permalink.gmane.org/gmane.comp.lang.scala/19439 the plugin is loaded by default, but it must be enabled by the command line argument -P:continuations:enable

    Read the article

  • how to make a JSON call to a url?

    - by Haroldo
    Hi I'm looking at the following API http://wiki.github.com/soundcloud/api/oembed-api the example they give Call: http://soundcloud.com/oembed?url=http%3A//soundcloud.com/forss/flickermood&format=json Response: { "html":"<object height=\"81\" ... ", "user":"Forss", "permalink":"http:\/\/soundcloud.com\/forss\/flickermood", "title":"Flickermood", "type":"rich", "provider_url":"http:\/\/soundcloud.com", "description":"From the Soulhack album...", "version":1.0, "user_permalink_url":"http:\/\/soundcloud.com\/forss", "height":81, "provider_name":"Soundcloud", "width":0 } What do i have to do to get this json object from just a url?!!?

    Read the article

  • ForEach loop: Output something different on every second result

    - by Wade D Ouellet
    I have two for each loops and I am trying to output something different for each second result: foreach ($wppost as $wp) { $wp_title = $wp->post_title; $wp_date = strtotime($wp->post_date); $wp_slug = $wp->post_name; $wp_id = $wp->ID; // Start Permalink Template $wp_showurl = $wp_url; $wp_showurl = str_replace("%year%", date('Y', $wp_date), $wp_showurl); $wp_showurl = str_replace("%monthnum%", date('m', $wp_date), $wp_showurl); $wp_showurl = str_replace("%day%", date('d', $wp_date), $wp_showurl); $wp_showurl = str_replace("%hour%", date('H', $wp_date), $wp_showurl); $wp_showurl = str_replace("%minute%", date('i', $wp_date), $wp_showurl); $wp_showurl = str_replace("%second%", date('s', $wp_date), $wp_showurl); $wp_showurl = str_replace("%postname%", $wp_slug, $wp_showurl); $wp_showurl = str_replace("%post_id%", $wp_id, $wp_showurl); // Stop Permalink Template $wp_posturl = $blog_address . $wp_showurl; echo '<li><a href="'.$wp_posturl.'" title="'.$wp_title.'">'.$wp_title.'</a></li>'; } For this one I want it to echo li class="even" instead of just li for each second result. I think this will have to be changed to a for loop to accomplished this but I am not sure how that is done without breaking it. Exact same for this one: if(is_array($commenters)) { foreach ($commenters as $k) { ?><li><?php if($ns_options["make_links"] == 1) { $url = ns_get_user_url($k->poster_id); if(trim($url) != '') { echo "<a href='" . $url . "'>"; } } if($ns_options["make_links"] == 2) { $url = ns_get_user_profile($k->poster_id); echo "<a href='" . $url . "'>"; } $name = $bbdb->get_var(" SELECT user_login FROM $bbdb->users WHERE ID = $k->poster_id"); echo ns_substr_ellipse($name, $ns_options["name_limit"]); if(trim($url) != '' && $ns_options["make_links"] == 1) { echo "</a>"; } if($ns_options["make_links"] == 2) { echo "</a>"; } if ($ns_options["show_posts"] == 1) { echo " (" . $k->num_posts . ")\n"; } echo $ns_options["end_html"] . "\n"; unset($url); } } else { ?></li><?php } Thanks, Wade

    Read the article

  • List of valid characters for the fragment identifier in an URL?

    - by sohtimsso1970
    I'm using the fragment identifier to create a permalink for AJAX events in my web app similar to this guy. Something like: http://www.myapp.com/calendar#filter:year/2010/month/5 I've done quite a bit of searching but can't find a list of valid characters for the fragment idenitifer. The W3C spec doesn't offer anything. Do I need to encode the characters the same as the URL in has in general? There doesn't seem to be any good information on this anywhere.

    Read the article

  • Wordpress: How to be redirected to the page when inserting it's page ID into numeric form input with

    - by Daniel
    I would like to know if there's exists some simple code to get to the page i know its ID , I would like to create small input (no matter where in templates)from where the people can easily get to the page if they know it's page ID (4numeric ID is better to remember - permalink name you can mistake . I have the girls portfolio in wordpress - portfolio=pages x jobs in clubs offers=posts , I would like the girls portfolios to be easily findable by ID(s) , if possible the same for the posts=jobs in clubs The best solution little 4-5numeric input and send=go button in sidebar.php - index.php etc

    Read the article

  • What's the logic flaw in this conditional?

    - by Scott B
    I've created this code branch so that if the permalink settings do no match at least one of the OR conditions, I can execute the "do something" branch. However, I believe there is a flaw in the logic, since I've set permalinks to /%postname%.html and it still tries echo's true; I believe I need to change the ORs to AND, right? if (get_option('permalink_structure') !== "/%postname%/" || get_option('my_permalinks') !== "/%postname%/" || get_option('permalink_structure') !== "/%postname%.html" || get_option('my_permalinks') !== "/%postname%.html")) { //do something echo "true"; }

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >