Search Results

Search found 4571 results on 183 pages for 'posts'.

Page 11/183 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • PHP + jQuery - undefined index: , but it still posts successfully?

    - by Ben Bernards
    When inserting a record to a database, the server returns an 'undefined index: category', error, but still posts the successfully... $('#button).click(function(){ var newvendor = $('#input_vendor).val(); newplantcode = $('#input_plantcode).val(); newcategory = $('#input_category).val(); $.post("php/addSite.php", {vendor: newvendor, plant_code: newplantcode, category: newcategory}, // <--- Error on this line, for some reason... function(result){ console.log("server returned : " + result); [ RELOAD THE PAGE ] }

    Read the article

  • Maintaining shared service in ASP.NET MVC Application

    - by kazimanzurrashid
    Depending on the application sometimes we have to maintain some shared service throughout our application. Let’s say you are developing a multi-blog supported blog engine where both the controller and view must know the currently visiting blog, it’s setting , user information and url generation service. In this post, I will show you how you can handle this kind of case in most convenient way. First, let see the most basic way, we can create our PostController in the following way: public class PostController : Controller { public PostController(dependencies...) { } public ActionResult Index(string blogName, int? page) { BlogInfo blog = blogSerivce.FindByName(blogName); if (blog == null) { return new NotFoundResult(); } IEnumerable<PostInfo> posts = postService.FindPublished(blog.Id, PagingCalculator.StartIndex(page, blog.PostPerPage), blog.PostPerPage); int count = postService.GetPublishedCount(blog.Id); UserInfo user = null; if (HttpContext.User.Identity.IsAuthenticated) { user = userService.FindByName(HttpContext.User.Identity.Name); } return View(new IndexViewModel(urlResolver, user, blog, posts, count, page)); } public ActionResult Archive(string blogName, int? page, ArchiveDate archiveDate) { BlogInfo blog = blogSerivce.FindByName(blogName); if (blog == null) { return new NotFoundResult(); } IEnumerable<PostInfo> posts = postService.FindArchived(blog.Id, archiveDate, PagingCalculator.StartIndex(page, blog.PostPerPage), blog.PostPerPage); int count = postService.GetArchivedCount(blog.Id, archiveDate); UserInfo user = null; if (HttpContext.User.Identity.IsAuthenticated) { user = userService.FindByName(HttpContext.User.Identity.Name); } return View(new ArchiveViewModel(urlResolver, user, blog, posts, count, page, achiveDate)); } public ActionResult Tag(string blogName, string tagSlug, int? page) { BlogInfo blog = blogSerivce.FindByName(blogName); if (blog == null) { return new NotFoundResult(); } TagInfo tag = tagService.FindBySlug(blog.Id, tagSlug); if (tag == null) { return new NotFoundResult(); } IEnumerable<PostInfo> posts = postService.FindPublishedByTag(blog.Id, tag.Id, PagingCalculator.StartIndex(page, blog.PostPerPage), blog.PostPerPage); int count = postService.GetPublishedCountByTag(tag.Id); UserInfo user = null; if (HttpContext.User.Identity.IsAuthenticated) { user = userService.FindByName(HttpContext.User.Identity.Name); } return View(new TagViewModel(urlResolver, user, blog, posts, count, page, tag)); } } As you can see the above code heavily depends upon the current blog and the blog retrieval code is duplicated in all of the action methods, once the blog is retrieved the same blog is passed in the view model. Other than the blog the view also needs the current user and url resolver to render it properly. One way to remove the duplicate blog retrieval code is to create a custom model binder which converts the blog from a blog name and use the blog a parameter in the action methods instead of the string blog name, but it only helps the first half in the above scenario, the action methods still have to pass the blog, user and url resolver etc in the view model. Now lets try to improve the the above code, first lets create a new class which would contain the shared services, lets name it as BlogContext: public class BlogContext { public BlogInfo Blog { get; set; } public UserInfo User { get; set; } public IUrlResolver UrlResolver { get; set; } } Next, we will create an interface, IContextAwareService: public interface IContextAwareService { BlogContext Context { get; set; } } The idea is, whoever needs these shared services needs to implement this interface, in our case both the controller and the view model, now we will create an action filter which will be responsible for populating the context: public class PopulateBlogContextAttribute : FilterAttribute, IActionFilter { private static string blogNameRouteParameter = "blogName"; private readonly IBlogService blogService; private readonly IUserService userService; private readonly BlogContext context; public PopulateBlogContextAttribute(IBlogService blogService, IUserService userService, IUrlResolver urlResolver) { Invariant.IsNotNull(blogService, "blogService"); Invariant.IsNotNull(userService, "userService"); Invariant.IsNotNull(urlResolver, "urlResolver"); this.blogService = blogService; this.userService = userService; context = new BlogContext { UrlResolver = urlResolver }; } public static string BlogNameRouteParameter { [DebuggerStepThrough] get { return blogNameRouteParameter; } [DebuggerStepThrough] set { blogNameRouteParameter = value; } } public void OnActionExecuting(ActionExecutingContext filterContext) { string blogName = (string) filterContext.Controller.ValueProvider.GetValue(BlogNameRouteParameter).ConvertTo(typeof(string), Culture.Current); if (!string.IsNullOrWhiteSpace(blogName)) { context.Blog = blogService.FindByName(blogName); } if (context.Blog == null) { filterContext.Result = new NotFoundResult(); return; } if (filterContext.HttpContext.User.Identity.IsAuthenticated) { context.User = userService.FindByName(filterContext.HttpContext.User.Identity.Name); } IContextAwareService controller = filterContext.Controller as IContextAwareService; if (controller != null) { controller.Context = context; } } public void OnActionExecuted(ActionExecutedContext filterContext) { Invariant.IsNotNull(filterContext, "filterContext"); if ((filterContext.Exception == null) || filterContext.ExceptionHandled) { IContextAwareService model = filterContext.Controller.ViewData.Model as IContextAwareService; if (model != null) { model.Context = context; } } } } As you can see we are populating the context in the OnActionExecuting, which executes just before the controllers action methods executes, so by the time our action methods executes the context is already populated, next we are are assigning the same context in the view model in OnActionExecuted method which executes just after we set the  model and return the view in our action methods. Now, lets change the view models so that it implements this interface: public class IndexViewModel : IContextAwareService { // More Codes } public class ArchiveViewModel : IContextAwareService { // More Codes } public class TagViewModel : IContextAwareService { // More Codes } and the controller: public class PostController : Controller, IContextAwareService { public PostController(dependencies...) { } public BlogContext Context { get; set; } public ActionResult Index(int? page) { IEnumerable<PostInfo> posts = postService.FindPublished(Context.Blog.Id, PagingCalculator.StartIndex(page, Context.Blog.PostPerPage), Context.Blog.PostPerPage); int count = postService.GetPublishedCount(Context.Blog.Id); return View(new IndexViewModel(posts, count, page)); } public ActionResult Archive(int? page, ArchiveDate archiveDate) { IEnumerable<PostInfo> posts = postService.FindArchived(Context.Blog.Id, archiveDate, PagingCalculator.StartIndex(page, Context.Blog.PostPerPage), Context.Blog.PostPerPage); int count = postService.GetArchivedCount(Context.Blog.Id, archiveDate); return View(new ArchiveViewModel(posts, count, page, achiveDate)); } public ActionResult Tag(string blogName, string tagSlug, int? page) { TagInfo tag = tagService.FindBySlug(Context.Blog.Id, tagSlug); if (tag == null) { return new NotFoundResult(); } IEnumerable<PostInfo> posts = postService.FindPublishedByTag(Context.Blog.Id, tag.Id, PagingCalculator.StartIndex(page, Context.Blog.PostPerPage), Context.Blog.PostPerPage); int count = postService.GetPublishedCountByTag(tag.Id); return View(new TagViewModel(posts, count, page, tag)); } } Now, the last thing where we have to glue everything, I will be using the AspNetMvcExtensibility to register the action filter (as there is no better way to inject the dependencies in action filters). public class RegisterFilters : RegisterFiltersBase { private static readonly Type controllerType = typeof(Controller); private static readonly Type contextAwareType = typeof(IContextAwareService); protected override void Register(IFilterRegistry registry) { TypeCatalog controllers = new TypeCatalogBuilder() .Add(GetType().Assembly) .Include(type => controllerType.IsAssignableFrom(type) && contextAwareType.IsAssignableFrom(type)); registry.Register<PopulateBlogContextAttribute>(controllers); } } Thoughts and Comments?

    Read the article

  • Architecture for a site "blog"/"news reel"

    - by DavidScherer
    I really don't want to undertake handling blog/news posts within a site I'm working on and would much rather use some other software that's fairly bare-bones that will manage the posts and then I can just pull posts from the DB or an API. Does anyone have any experience with a nice, lightweight OS Blog type software that has either an API or is basic enough to simply pull Data from the database? I really only need the software for managing, I plan to display all the posts programatically through MVC.

    Read the article

  • Good way to manage blog/news? [closed]

    - by DavidScherer
    I really don't want to undertake handling blog/news posts within a site I'm working on and would much rather use some other software that's fairly bare-bones that will manage the posts and then I can just pull posts from the DB or an API. Does anyone have any experience with a nice, lightweight OS Blog type software that has either an API or is basic enough to simply pull Data from the database? I really only need the software for managing, I plan to display all the posts programatically through MVC.

    Read the article

  • How can i have custom fields on the posts page in wordpress?

    - by Luccas
    First I've created a home.php page to replace index.php and can add some custom fields on this new one and to have in it lastest 3 posts. On home.php page I put: <?php echo get_post_meta($post->ID, 'test', true); ?>"/> but it doesn't works cause it tries get the post id and not the id of the page. If i put 18 (id of the page) directly it works, but i want it dinamicaly: <?php echo get_post_meta(18, 'test', true); ?>"/> And this condition is not satisfied for test: if($post->post_type == 'page'){ echo 'This item is a page and the ID is: '.$post->ID; }

    Read the article

  • Coding a Tumblr Theme - List posts as list or just a stack of divs?

    - by Trippy
    I'm in the process of coding my own Tumblr Theme. Well I was wondering how should I list the posts? In the basic theme, (the one you get when you sign up) doesn't use list items (<li>). But I saw in another theme that it does use list items. By the way, this is what I mean... <div class="post-text"><div> <div class="post-audio"><div> ... or <ul> <li class="post-text"></li> ... </ul> I'm confused on the way I should go - I want to go to the semantic way of doing it because the theme will be built in HTML5.

    Read the article

  • I want to use facebook connect in my website to register, login and comment on news articles or posts made by other users

    - by sasi kiran
    I would like to implement the following things in my website. I have done some extensive search over the internet but couldnt find and specific examples on how to implement them I am developing this site in php using a mvc framework Would like to have facebook registration on my website - users who have an account in facebook will get an option to use the details to register in my site, using their authentication I would pull the relavant details from their account and create a new account for them in my website. I would like to use facebook register fbml/fbjs in this case Would like to have facebook login used to login into my site. How to use the sessions is what I would like to know? I would like to make posts to the facebook-wall of the users registered in my site. Also if possible sent messages to them through my code whenever a new post is made to my site. Thanks for your help.

    Read the article

  • How to programmatically fetch posts matching a search query in WordPress?

    - by Alan Bellows
    In my plugin code I would like to perform a WP_Query (or similar) which returns all posts matching a given query string, as if the user typed that same string into the WordPress search form. Perhaps I'm just being dense, but I cannot seem to find a way to do so. I would expect to have a special parameter for WP_Query, such as matching, but I see no evidence of one. I'll start going through the WordPress codebase to see how it's done internally, and I'll post the answer here if I find it. I just thought someone might happen to know offhand.

    Read the article

  • When I write a post on the board, with the posts and tried to put the image into

    - by bismute
    When I write a post on the board, with the posts and tried to put the image into. When I add an image, the text in the image are about to enter. <?php $reg_date = time(); $member_idx = $_POST['member_idx']; $q = "INSERT INTO ap_bbs (member_idx, subject,content,reg_date) VALUES('$member_idx', '$subject', '$content', '$reg_date')"; $result = $mysqli->query($q); if ($result==false) { $_SESSION['writing_status'] = 'NO'; } else { $_SESSION['writing_status'] = 'YES'; } $mysqli->close(); ?> Writing, I think the logic is as follows, where the images in the attachment content and I'm wondering if there is any way to put.

    Read the article

  • Remaking this loop by user?

    - by Elliot
    I'm wondering if theres a best practice for what I'm trying to accomplish... First we have the model categories, categories, has_many posts. Now lets say, users add posts. Now, I have a page, that I want to display only the current user's posts by category. Lets say we have the following categories: A, B, and C User 1, has posted in Categories A and B. In my view I have something like: <% @categories.select {|cat| cat.posts.count > 0}.each do |category| %> <%= category.name %><br/> <% category.posts.select {|post| post.user == current_user}.each do |post| %> <%= post.content %><br/> <% end %> <% end %> For the most part its almost there. The issue is, it will still show an empty category if any posts have been entered in it at all (even if the current user has not input posts into that category. So the question boils down to: How do I make the following loop only count posts in the category from the current user? <% @categories.select {|cat| cat.posts.count 0}.each do |category| % Best, Elliot

    Read the article

  • Getting the most recent post based on date

    - by camcim
    Hi guys, How do I go about displaying the most recent post when I have two tables, both containing a column called creation_date This would be simple if all I had to do was get the most recent post based on posts created_on value however if a post contains replies I need to factor this into the equation. If a post has a more recent reply I want to get the replies created_on value but also get the posts post_id and subject. The posts table structure: CREATE TABLE `posts` ( `post_id` bigint(20) unsigned NOT NULL auto_increment, `cat_id` bigint(20) NOT NULL, `user_id` bigint(20) NOT NULL, `subject` tinytext NOT NULL, `comments` text NOT NULL, `created_on` datetime NOT NULL, `status` varchar(10) NOT NULL default 'INACTIVE', `private_post` varchar(10) NOT NULL default 'PUBLIC', `db_location` varchar(10) NOT NULL, PRIMARY KEY (`post_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; The replies table structure: CREATE TABLE `replies` ( `reply_id` bigint(20) unsigned NOT NULL auto_increment, `post_id` bigint(20) NOT NULL, `user_id` bigint(20) NOT NULL, `comments` text NOT NULL, `created_on` datetime NOT NULL, `notify` varchar(5) NOT NULL default 'YES', `status` varchar(10) NOT NULL default 'INACTIVE', `db_location` varchar(10) NOT NULL, PRIMARY KEY (`reply_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; Here is my query so far. I've removed my attempt of extracting the dates. $strQuery = "SELECT posts.post_id, posts.created_on, replies.created_on, posts.subject "; $strQuery = $strQuery."FROM posts ,replies "; $strQuery = $strQuery."WHERE posts.post_id = replies.post_id "; $strQuery = $strQuery."AND posts.cat_id = '".$row->cat_id."'";

    Read the article

  • Photo gallery for Blogspot blog

    - by Django Reinhardt
    I don't think this is entirely possible, but here we go: I have a friend who has a Blogspot blog. He has posts with text, posts with videos and posts with photos... and he was wondering if there's any way to turn the posts which are just photos into a thumbnail gallery screen on his blog. So for example, let's say he has 20 photo posts on his blog with the label Skiing Holiday 2009 (horrible example, I know). Is there a way of having a post created for his blog that displays those photos as thumbnails, linking through to their full size versions? I just don't think it's possible, but I'm really hoping someone will be able to offer a solution (or even a place where I could find a solution). Thanks a lot.

    Read the article

  • asp.net mvc client side validation; manually calling validation via javascript for ajax posts

    - by Jopache
    Under the built in client side validation (Microsoft mvc validation in mvc 2) using data annotations, when you try to submit a form and the fields are invalid, you will get the red validation summary next to the fields and the form will not post. However, I am using jquery form plugin to intercept the submit action on that form and doing the post via ajax. This is causing it to ignore validation; the red text shows up; but the form posts anyways. Is there an easy way to manually call the validation via javascript when I'm submitting the form? I am still kind of a javascript n00b. I tried googling it with no results and looking through the js source code makes my head hurt trying to figure it out. Or would you all recommend that I look in to some other validation framework? I liked the idea of jquery validate; but would like to define my validation requirements only in my viewmodel. Any experiences with xval or anything of the sort?

    Read the article

  • Custom Wordpress Post Page Breaks if More Thank 2 Posts?

    - by thatryan
    I have a very custom template, and it works great if there are 1 or 2 posts on the blog page. But as soon as a 3rd post is added, it alters the structure of the template... Literally moves a div inside of another and I can not understand why. The code for the blog template is here, and a screenshot of the structure as it should be and another showing the misplaced div when a third post is there. Does this make any sense, any ideas? Thank you much! <div class="post" id="post-<?php the_ID(); ?>"><!--start post--> <h2><?php the_title(); ?></h2> <div id="main_full" class=" clearfix"><!--start main--> <div id="top_bar"><h3 class="gallery-title">news</h3></div> <div id="blog_page"><!--start blog page--> <div class="entry"><!--start entry--> <?php the_content(); ?> </div><!--end entry--> </div><!--end blog page--> </div><!--end main--> <?php endwhile; endif; ?> </div><!--end post--> <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?> <?php comments_template(); ?> Good One Bad One

    Read the article

  • Getting the number of posts a user has by the number of rows returned?

    - by transparent
    So I have a question. I have chatting/IM website that I am working on and I was making a user profile page. I wanted to show how many posts that user had. Another issue I had earlier was that when I called a certain value it would return a 'Resource #1' type string. But I got that working by using $totalposts=mysql_query("SELECT * FROM `posts` WHERE Username='" . $username . "'"); $totalposts = mysql_fetch_row($totalposts); $totalposts = $totalposts[0]; But that just returns the last postID of the most recent post. I thought that mysql_num_rows would work. But this code returns an error (example with numbers): 29: $totalposts=mysql_query("SELECT * FROM `posts` WHERE Username='" . $username . "'"); 30: $totalposts = mysql_num_rows($totalposts); 31: $totalposts =mysql_fetch_row($totalposts); 32: $totalposts = $totalposts[0]; That returns this error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/a9091503/public_html/im/user.php on line 31 Thanks guys. :) I hope you can figure this out. :D

    Read the article

  • PLT Scheme URL dispatch

    - by Inaimathi
    I'm trying to hook up URL dispatch with PLT Scheme. I've taken a look at the tutorial and the server documentation. I can figure out how to route requests to the same servlets. Specific example: (define (start request) (blog-dispatch request)) (define-values (blog-dispatch blog-url) (dispatch-rules (("") list-posts) (("posts" (string-arg)) review-post) (("archive" (integer-arg) (integer-arg)) review-archive) (else list-posts))) (define (list-posts req) `(list-posts)) (define (review-post req p) `(review-post ,p)) (define (review-archive req y m) `(review-archive ,y ,m)) Assuming the above code running on a server listening 8080, localhost:8080/ goes to a page that says "list-posts". Going to localhost:8080/posts/test goes to a PLT "file not found" page (with the above code, I'd expect it to go to a page that says "review-post test"). It feels like I'm missing something small and obvious. Can anyone give me a hint?

    Read the article

  • SQL to retrieve the latest records, grouping by unique foreign keys

    - by jbox
    I'm creating query to retrieve the latest posts in a forum using a SQL DB. I've got a table called "Post". Each post has a foreign key relation to a "Thread" and a "User" as well as a creation date. The trick is I don't want to show two posts by the same user or two posts in the same thread. Is it possible to create a query that contains all this logic? # Grab the last 10 posts. SELECT id, user_id, thread_id FROM posts ORDER BY created_at DESC LIMIT 10; # Grab the last 10 posts, max one post per user SELECT id, user_id, thread_id FROM post GROUP BY user_id ORDER BY date DESC LIMIT 10; # Grab the last 10 posts, max one post per user, max one post per thread???

    Read the article

  • Best of "The Moth" 2012

    - by Daniel Moth
    As with previous years (2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011) I’d like to wish you a Happy New Year and share a quick review of my blog posts from 2012 (plus speculate on my 2013 blog focus). 1. Like 2011, my professional energy in 2012 was dominated by C++ AMP including articles, blog posts, demos, slides, and screencasts. I summarized that over two posts on the official team blog that I linked to from my blog post here titled: “The last word on C++ AMP”, which also subtly hinted at my change of role which I confirmed in my other post titled “Visual Studio Continued Excitement”. 2. Even before I moved to the Visual Studio Diagnostics team in September, earlier in the year I had started sharing blog posts with my thoughts on that space, something I expect to continue in the new year. You can read some of that in these posts: The way I think about Diagnostic tools, Live Debugging, Attach to Process in Visual Studio, Start Debugging in Visual Studio, Visual Studio Exceptions dialogs. 3. What you should also expect to see more of is thoughts, tips, checklists, etc around Professional Communication and on how to be more efficient and effective with that, e.g. Link instead of Attaching, Sending Outlook Invites, Responding to Invites, and OOF checklist. 4. As always, I sometimes share random information, and noteworthy from 2012 is the one where I outlined the Visual Studio versioning story (“Visual Studio 11 not 2011”, and after that post VS 11 was officially baptized VS2012) and the one on “How I Record Screencasts”. Looking back, unlike 2011 there were no posts in 2012 related to device development, e.g. for Windows Phone. Expect that to be rectified in 2013 as I hope to find more time for such coding… stay tuned by subscribing using the link on the left. Comments about this post by Daniel Moth welcome at the original blog.

    Read the article

  • Using MongoDB with Ruby On Rails and the Mongomapper plugin

    - by Micke
    Hello, i am currently trying to learn Ruby On Rails as i am a long-time PHP developer so i am building my own community like page. I have came pritty far and have made the user models and suchs using MySQL. But then i heard of MongoDB and looked in to it a little bit more and i find it kinda nice. So i have set it up and i am using mongomapper for the connection between rails and MongoDB. And i am now using it for the News page on the site. I also have a profile page for every User which includes their own guestbook so other users can come to their profile and write a little message to them. My thought now is to change the User models from using MySQL to start using MongoDB. I can start by showing how the models for each User is set up. The user model: class User < ActiveRecord::Base has_one :guestbook, :class_name => "User::Guestbook" The Guestbook model model: class User::Guestbook < ActiveRecord::Base belongs_to :user has_many :posts, :class_name => "User::Guestbook::Posts", :foreign_key => "user_id" And then the Guestbook posts model: class User::Guestbook::Posts < ActiveRecord::Base belongs_to :guestbook, :class_name => "User::Guestbook" I have divided it like this for my own convenience but now when i am going to try to migrate to MongoDB i dont know how to make the tables. I would like to have one table for each user and in that table a "column" for all the guestbook entries since MongoDB can have a EmbeddedDocument. I would like to do this so i just have one Table for each user and not like now when i have three tables just to be able to have a guestbook. So my thought is to have it like this: The user model: class User include MongoMapper::Document one :guestbook, :class_name => "User::Guestbook" The Guestbook model model: class User::Guestbook include MongoMapper::EmbeddedDocument belongs_to :user many :posts, :class_name => "User::Guestbook::Posts", :foreign_key => "user_id" And then the Guestbook posts model: class User::Guestbook::Posts include MongoMapper::EmbeddedDocument belongs_to :guestbook, :class_name => "User::Guestbook" But then i can think of one problem.. That when i just want to fetch the user information like a nickname and a birthdate then it will have to fetch all the users guestbook posts. And if each user has like a thousand posts in the guestbook it will get really much to fetch for the system. Or am i wrong? Do you think i should do it any other way? Thanks in advance and sorry if i am hard to understand but i am not so educated in the english language :)

    Read the article

  • mysql select top users problem

    - by moustafa
    i have users table and i have posts table i want select from users the top users that have the big amount of posts from posts table and order them by numbers of posts i can make it by array_count_values() by i cant order it now i think if i make it by one mysql query by left and join will be more better table structure posts id | auther_id

    Read the article

  • Mysql: Perform of NOT EXISTS. Is it possible to improve permofance?

    - by petRUShka
    I have two tables posts and comments. Table comments have post_id attribute. I need to get all posts with type "open", for which there are no comments with type "good" and created date MAY 1. Is it optimal to use such SQL-query: SELECT posts.* FROM posts WHERE NOT EXISTS ( SELECT comments.id FROM comments WHERE comments.post_id = posts.id AND comments.comment_type = 'good' AND comments.created_at BETWEEN '2010-05-01 00:00:00' AND '2010-05-01 23:59:59') I'm not sure that NOT EXISTS is perfect construction in this situation.

    Read the article

  • How to return number of rows in the template

    - by xRobot
    In my view I return all posts of one blog: posts = Post.objects.filter(blog=blog) and pass it to context. But.. How can I get the number of posts in the template ? This is my template: <h1>Number of posts: {{ ??? }} </h1> {% for post in posts %} {{ post.title }} {{ post.body }} {% endfor %}

    Read the article

  • MySQL subqueries

    - by swamprunner7
    Can we do this query without subqueries? SELECT login, post_n, (SELECT SUM(vote) FROM votes WHERE votes.post_n=posts.post_n)AS votes, (SELECT COUNT(comments.post_n) FROM comments WHERE comments.post_n=posts.post_n)AS comments_count FROM users, posts WHERE posts.id=users.id AND (visibility=2 OR visibility=3) ORDER BY date DESC LIMIT 0, 15 tables: Users: id, login Posts: post_n, id, visibility Votes: post_n, vote id — it`s user id, Users the main table.

    Read the article

  • Rails 3 Atom Feed

    - by scud bomb
    Trying to create an atom feed in Rails 3. When i refresh my browser i see basic XML, not the Atom feed im looking for. class PostsController < ApplicationController # GET /posts # GET /posts.xml def index @posts = Post.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @posts } format.atom end end index.atom.builder atom_feed do |feed| feed.title "twoconsortium feed" @posts.each do |post| feed.entry(post) do |entry| entry.title post.title entry.content post.text end end end localhost:3000/posts.atom looks like this: <?xml version="1.0" encoding="UTF-8"?> <feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom"> <id>tag:localhost,2005:/posts</id> <link rel="alternate" type="text/html" href="http://localhost:3000"/> <link rel="self" type="application/atom+xml" href="http://localhost:3000/posts.atom"/> <title>my feed</title> <entry> <id>tag:localhost,2005:Post/1</id> <published>2012-03-27T18:26:13Z</published> <updated>2012-03-27T18:26:13Z</updated> <link rel="alternate" type="text/html" href="http://localhost:3000/posts/1"/> <title>First post</title> <content>good stuff</content> </entry> <entry> <id>tag:localhost,2005:Post/2</id> <published>2012-03-27T19:51:18Z</published> <updated>2012-03-27T19:51:18Z</updated> <link rel="alternate" type="text/html" href="http://localhost:3000/posts/2"/> <title>Second post</title> <content>its that second post type stuff</content> </entry> </feed>

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >