categories

Category relationship in laravel Undefined property: stdClass::

谁说胖子不能爱 提交于 2019-12-12 03:08:57
问题 Hi i'm working on a laravel training project . i'm having an issue with models and relationships when i'm trying to get the each product category name . Here is my Product Model <?php namespace App; use Illuminate\Database\Eloquent\Model; class Product extends Model { public function category() { return $this->belongsTo('App\Category'); } } and my Category model <?php namespace App; use Illuminate\Database\Eloquent\Model; class Category extends Model { protected $table = 'categories'; public

Categories with Subcategories in table - PHP + MYSQL

佐手、 提交于 2019-12-12 02:31:46
问题 I have Categories and Sub-Categories on my database. Database table contain "cid" , "pid" and "cname" columns. Cid = Categories ID Pid = If Category is a Sub-Category , then Pid = that belong which category. Cname = Category Name For Example Software is a category and id = 15 and "IOS Software is a sub-category and id= 30 and pid = 15 Now I want to show this Cat. And Sub-Cat in a table. Here is my code: <?php function categories() { $categorysql = $DB['DB_Database']->query("SELECT cid, pid,

Place category_description in the meta description (wordpress)

我只是一个虾纸丫 提交于 2019-12-12 01:58:08
问题 Header in my theme I created the following code for the meta description: <?php if (is_single() || is_page()) { ?> <meta name="description" content="<?php echo metadesc($post->ID); ?>" /> <?php }else{ ?> <meta name="description" content="<?php bloginfo('description'); ?>" /> <?php } ?> and included this code in my function.php: function metadesc($pid) { $p = get_post($pid); $description = strip_tags($p->post_content); $description = str_replace ("\n","",$description); $description = str

Android Email Intent

谁说胖子不能爱 提交于 2019-12-11 19:53:54
问题 I've set up two buttons. One opens the compose sms intent and the other opens the compose email intent. The sms intent works fine but the email button doesnt respond. Ive created a categorychooser but that doesnt show up....UNTIL I click the sms button This is my code case R.id.button2: { String phoneNumber = "xxxxxxxxxx";`` Intent smsIntent = new Intent(Intent.ACTION_SENDTO); smsIntent.addCategory(Intent.CATEGORY_DEFAULT); smsIntent.setType("vnd.android -dir/mms-sms"); smsIntent.setData(Uri

Show custom text field on category list page

喜夏-厌秋 提交于 2019-12-11 19:35:57
问题 I've added a custom module for adding an extra description to category pages. It's showing in Admin but I can't get it to show on category frontend pages. I'm probably not understanding the childtheme inheritance structure. I've read and tried every article here but none of them provide the exact information I need. Luma Childtheme is active: app>design>frontend>MyCompany>Luma_child Custom module: app>code>MyCompany>CategoryAttribute I've tried adding app/code/MyCompany/CategoryAttribute/view

show post from the same category when you click previous/next button wordpress

柔情痞子 提交于 2019-12-11 19:26:21
问题 I have the below issue. When I click to the previous/next button of the same category unfortunately i receive the previous/next post hronologically instead of the previous/next post of the same category. Here is the code: < div id="previous_post"> < ?php previous_post_link( '%link', __( '<span class="prev"><< Preivous Post</span>', 'esquire' ) ); ? > < /div> < div id="next_post"> < ?php next_post_link( '%link', __( '<span class="next">Next Post >></span>', 'esquire' ) ); ? > < /div> I've

Randomise & limit Category thumbs on homepage magento

一个人想着一个人 提交于 2019-12-11 19:15:16
问题 The following code simply displays the category thumbs for all subcategories in "category 12" im looking for a way to limit this number to 6 categories and have it be a random selection of those categories. <ul class="brand_list"> <?php $media = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?> <?php $children = Mage::getModel('catalog/category')->getCategories(12); ?> <?php foreach ($children as $category): ?> <?php $category = Mage::getModel('catalog/category')->load($category-

WordPress: Show all posts from specific category

喜欢而已 提交于 2019-12-11 18:48:19
问题 I Need to show latest post from a specified category in WordPress. The category is " News World ", and I am try this code but show me all post from all category. $wp_query = new WP_Query( array( 'post_type' => 'post', 'paged' => $paged ) ); 回答1: <?php $custom_query = new WP_Query('cat=9'); //your category id while($custom_query->have_posts()) : $custom_query->the_post(); ?> //loop items go here <?php endwhile; ?> <?php wp_reset_postdata(); // reset the query ?> 回答2: Do this: $wp_query = new

How to get the item count for sub-categories on each parent?

十年热恋 提交于 2019-12-11 16:41:01
问题 This is related to the following post: The function that retrieves the item counts for each folder (category) is: ALTER FUNCTION [dbo].[GetFolderReceiptCount] ( -- Add the parameters for the function here @FolderID bigint ) RETURNS int AS BEGIN DECLARE @Return int SET @Return = 0 SELECT --H.ReceiptFolderID, @Return = COUNT(H.ReceiptFolderID) FROM tbl_ReceiptFolderLnk H JOIN tbl_Receipt D ON H.ReceiptID = D.ReceiptID WHERE ReceiptFolderID=@FolderID GROUP BY H.ReceiptFolderID -- Return the

How can I set the limit number of the posts of a specify category into a page of that category?

倖福魔咒の 提交于 2019-12-11 16:21:20
问题 I would to know how can I set the limit number of the posts visible into a page of a specify category. 回答1: Put this in your functions.php function main_query_mods( $query ) { if(!$query->is_main_query()) { return; } // show 15 posts per page if category has id 7 // check http://codex.wordpress.org/Conditional_Tags#A_Category_Page if ( is_category('7')) { $query->set('posts_per_page',15); } } add_action( 'pre_get_posts', 'main_query_mods' ); 回答2: You should use this: <?php $the_query = new WP