• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help related to my codeigniter wallpaper script

#31
It's being replace with Javascript.
/themes/default/assets/js/main.min.js
Code:
$(".good-res").length && ($(".dl_links").data("width") >= screen.width && $(".dl_links").data("height") >= screen.height ? $(".good-res").each(function(t, e) {
           $(e).attr("href", $(e).attr("href").replace("{R_WIDTH}", screen.width).replace("{R_HEIGHT}", screen.height)).removeClass("hide")
       }) : ($(".dl_links").remove(), $(".dl_links_error").removeClass("hide"))), $(".wpd").on("click", function() {
           noty({
               text: $(this).data("msg"),
               type: "success"
           })
       })

You need to modify your build_link so that it dosen't add {R_WIDTH}x{R_HEIGHT} and later on append the URL with javascript instead of replacing it.
Reply

#32
(02-21-2018, 10:12 AM)jreklund Wrote: It's being replace with Javascript.
/themes/default/assets/js/main.min.js
Code:
$(".good-res").length && ($(".dl_links").data("width") >= screen.width && $(".dl_links").data("height") >= screen.height ? $(".good-res").each(function(t, e) {
           $(e).attr("href", $(e).attr("href").replace("{R_WIDTH}", screen.width).replace("{R_HEIGHT}", screen.height)).removeClass("hide")
       }) : ($(".dl_links").remove(), $(".dl_links_error").removeClass("hide"))), $(".wpd").on("click", function() {
           noty({
               text: $(this).data("msg"),
               type: "success"
           })
       })

You need to modify your build_link so that it dosen't add {R_WIDTH}x{R_HEIGHT} and later on append the URL with javascript instead of replacing it.

Hi. Smile

Thanks for the hint.

I improvised something that seems to work.

Cheers!
Reply

#33
Hi again!

In the past months i understand a lot CI working mechanism and i like it a lot.

But now for the past 3 hours I can't find a solution for this problem:

PHP Code:
        <?php foreach ($categories as $k => $cat) { ?>
        <div class="item">
            <div class="thumbnail">
                <div class="pr">
                <?php $search_replace = array('{C_SLUG_FULL}' => $cat->cFullSlug'{C_SLUG}' => $cat->category_slug); ?><?php $front_link $this->route_links->build_link('category_page'$search_replace); ?>
                    <a href="<?php echo $front_link?>">
                        <img src="<?php echo $this->image_workshop->crop_image(ORIGINALS_FOLDER_WF '/' $cat->wallpaper_image_path400225$cat->wallpaper_crop_position'thumbnail'); ?>" alt="<?php echo $cat->category_name?>"/>
                    </a>
                    <h2 class="cat-page-index"><?php echo $cat->category_name?></h2>
                </div>
            </div>
        </div>
        <?php ?>


This line of code <img src="<?php echo $this->image_workshop->crop_image(ORIGINALS_FOLDER_WF . '/' . $cat->wallpaper_image_path, 400, 225, $cat->wallpaper_crop_position, 'thumbnail'); ?>" alt="<?php echo $cat->category_name; ?>"/> generates my thumbnails in this page https://uhdwallpapers.org/categories/

and what i need is to make it to choose the newest thumbnail not the 1st that was published when the category was created.

Can someone tell me how to modify the code to choose the newest thumbnail for every category? (i guess it is something related to order by or reverse for foreach, but i don't know how to implement)


Thank you!
Reply

#34
Does $categories contain all images? (This should be no, or else you should have duplicates)
You need to look at the function that generates $categories, it's got nothing to do with this foreach. But you are on the right track. You can possible add DESC in your SQL, or similar. Depending on how the SQL looks and the database design.
Reply

#35
Damn, i can't figure it out what to do to make it work.

Here's the code for $categories:

PHP Code:
$data['categories'] = $this->category_model->get_parent_categories(); 


And for the get_parent_categories below is the code.

PHP Code:
   public function get_parent_categories()
 
   {
 
       $views $this->wallpaperViews();
 
       $this->db->select('wp.category_seq_id as wpcid,w.*');
 
       $this->db->from('wallpapers_path wp');
 
       $this->db->join('wallpapers w''w.wallpaper_seq_id = wp.wallpaper_seq_id');
 
       $this->db->join("($views) as v"'v.wv_wid = w.wallpaper_seq_id''left');
 
       $this->db->group_by('wp.category_seq_id');
 
       $this->db->order_by('total_views''desc');
 
       $wallpaper_sql $this->sql();

 
       $this->db->select('w.*');
 
       $this->wallCatTemplate(false);
 
       $this->db->join("($wallpaper_sql) as w"'w.wpcid = c.category_seq_id''left');
 
       $this->db->where('w.wallpaper_seq_id IS NOT NULL');
 
       $this->db->order_by('t2.category_name''asc');
 
       return $this->result();
 
   


@jreklund let me know if you need anything else to figure it out, because in the past 4 hours i tried all kind of combination, but the only thing that changes is the order of categories and NOT the thumbnails.

Thanks!
Reply

#36
Hi, can you run this? And post the generated SQL. Can't really see where the category are.
It would also be helpful with a database structure, not the data. But what the tables/columns are named.

PHP Code:
public function get_parent_categories()
    {
        
$views $this->wallpaperViews();
        
$this->db->select('wp.category_seq_id as wpcid,w.*');
        
$this->db->from('wallpapers_path wp');
        
$this->db->join('wallpapers w''w.wallpaper_seq_id = wp.wallpaper_seq_id');
        
$this->db->join("($views) as v"'v.wv_wid = w.wallpaper_seq_id''left');
        
$this->db->group_by('wp.category_seq_id');
        
$this->db->order_by('total_views''desc');
        echo 
$wallpaper_sql $this->sql();

        
$this->db->select('w.*');
        
$this->wallCatTemplate(false);
        
$this->db->join("($wallpaper_sql) as w"'w.wpcid = c.category_seq_id''left');
        
$this->db->where('w.wallpaper_seq_id IS NOT NULL');
        
$this->db->order_by('t2.category_name''asc');
        echo 
$this->sql();
    } 
Reply

#37
Hi, thanks for trying to helping me.

This is what returns:


Code:
SELECT `wp`.`category_seq_id` as `wpcid`, `w`.* FROM `WS_wallpapers_path` `wp` JOIN `WS_wallpapers` `w` ON `w`.`wallpaper_seq_id` = `wp`.`wallpaper_seq_id` LEFT JOIN (SELECT `tv_views_count` as `total_views`, `tv_wid` as `wv_wid` FROM `WS_wallpapers_temp_views`) as v ON `v`.`wv_wid` = `w`.`wallpaper_seq_id` GROUP BY `wp`.`category_seq_id` ORDER BY `total_views` DESCSELECT `w`.*, `t2`.*, GROUP_CONCAT(c.category_slug order by c1.lvl desc SEPARATOR '/') AS cFullSlug, GROUP_CONCAT(c.category_name order by c1.lvl desc SEPARATOR '|') AS cFullName FROM `WS_closures` `c1` LEFT JOIN `WS_category` `c` ON `c`.`category_seq_id` = `c1`.`ancestor` LEFT JOIN `WS_category` `t2` ON `t2`.`category_seq_id` = `c1`.`descendant` LEFT JOIN (SELECT `wp`.`category_seq_id` as `wpcid`, `w`.* FROM `WS_wallpapers_path` `wp` JOIN `WS_wallpapers` `w` ON `w`.`wallpaper_seq_id` = `wp`.`wallpaper_seq_id` LEFT JOIN (SELECT `tv_views_count` as `total_views`, `tv_wid` as `wv_wid` FROM `WS_wallpapers_temp_views`) as v ON `v`.`wv_wid` = `w`.`wallpaper_seq_id` GROUP BY `wp`.`category_seq_id` ORDER BY `total_views` DESC) as w ON `w`.`wpcid` = `c`.`category_seq_id` WHERE `w`.`wallpaper_seq_id` IS NOT NULL GROUP BY `c1`.`descendant` ORDER BY `t2`.`category_name` ASC
And these are the tables involved:
table: WS_wallpapers_path -> with this columns:  wp_seq_id     wallpaper_seq_id     category_seq_id
table: WS_wallpapers -> with this columns:   wallpaper_seq_id     wallpaper_name     wallpaper_slug   category_seq_id     wallpaper_image_path
table: WS_wallpapers -> with this columns:  category_seq_id     category_slug     category_name     category_parent_id     category_status
table: WS_closures -> with this columns:  id     ancestor     descendant     lvl
table: WS_wallpapers_views -> with this columns:   wv_seq_id     wv_date     wv_ip     wv_uid     wv_wid
Reply

#38
Can you run these in phpmyadmin or similar and screenshot the results. I'm afraid it's too hard to actually see how it's behaving.

Code:
SELECT `wp`.`category_seq_id` as `wpcid`, `w`.* FROM `WS_wallpapers_path` `wp` JOIN `WS_wallpapers` `w` ON `w`.`wallpaper_seq_id` = `wp`.`wallpaper_seq_id` LEFT JOIN (SELECT `tv_views_count` as `total_views`, `tv_wid` as `wv_wid` FROM `WS_wallpapers_temp_views`) as v ON `v`.`wv_wid` = `w`.`wallpaper_seq_id` GROUP BY `wp`.`category_seq_id` ORDER BY `total_views` DESC

Code:
SELECT `w`.*, `t2`.*, GROUP_CONCAT(c.category_slug order by c1.lvl desc SEPARATOR '/') AS cFullSlug, GROUP_CONCAT(c.category_name order by c1.lvl desc SEPARATOR '|') AS cFullName FROM `WS_closures` `c1` LEFT JOIN `WS_category` `c` ON `c`.`category_seq_id` = `c1`.`ancestor` LEFT JOIN `WS_category` `t2` ON `t2`.`category_seq_id` = `c1`.`descendant` LEFT JOIN (
SELECT `wp`.`category_seq_id` as `wpcid`, `w`.* FROM `WS_wallpapers_path` `wp` JOIN `WS_wallpapers` `w` ON `w`.`wallpaper_seq_id` = `wp`.`wallpaper_seq_id` LEFT JOIN (SELECT `tv_views_count` as `total_views`, `tv_wid` as `wv_wid` FROM `WS_wallpapers_temp_views`) as v ON `v`.`wv_wid` = `w`.`wallpaper_seq_id` GROUP BY `wp`.`category_seq_id` ORDER BY `total_views` DESC
) as w ON `w`.`wpcid` = `c`.`category_seq_id` WHERE `w`.`wallpaper_seq_id` IS NOT NULL GROUP BY `c1`.`descendant` ORDER BY `t2`.`category_name` ASC

PHP Code:
public function get_parent_categories()
    {
        
$views $this->wallpaperViews();
        
$this->db->select('wp.category_seq_id as wpcid,w.*');
        
$this->db->from('wallpapers_path wp');
        
$this->db->join('wallpapers w''w.wallpaper_seq_id = wp.wallpaper_seq_id');
        
$this->db->join("($views) as v"'v.wv_wid = w.wallpaper_seq_id''left');
        
$this->db->group_by('wp.category_seq_id');
        
$this->db->order_by('wp.wp_seq_id''desc'); // This is just a wild guess
        
$this->db->order_by('total_views''desc');
        
$wallpaper_sql $this->sql();

        
$this->db->select('w.*');
        
$this->wallCatTemplate(false);
        
$this->db->join("($wallpaper_sql) as w"'w.wpcid = c.category_seq_id''left');
        
$this->db->where('w.wallpaper_seq_id IS NOT NULL');
        
$this->db->order_by('t2.category_name''asc');
        return 
$this->result();
    } 

PHP Code:
public function get_parent_categories()
    {
        
$views $this->wallpaperViews();
        
$this->db->select('wp.category_seq_id as wpcid,w.*');
        
$this->db->from('wallpapers_path wp');
        
$this->db->join('wallpapers w''w.wallpaper_seq_id = wp.wallpaper_seq_id');
        
$this->db->join("($views) as v"'v.wv_wid = w.wallpaper_seq_id''left');
        
$this->db->group_by('wp.category_seq_id');
        
$this->db->order_by('w.wallpaper_seq_id''desc'); // Another guess
        
$this->db->order_by('total_views''desc');
        
$wallpaper_sql $this->sql();

        
$this->db->select('w.*');
        
$this->wallCatTemplate(false);
        
$this->db->join("($wallpaper_sql) as w"'w.wpcid = c.category_seq_id''left');
        
$this->db->where('w.wallpaper_seq_id IS NOT NULL');
        
$this->db->order_by('t2.category_name''asc');
        return 
$this->result();
    } 
Reply

#39
@jreklund thank you for trying to help me, you're very kind.

I tried your solutions :Smile and not worked.

And i didn't found a solution at this time Sad

But, for now will remain as it is, because i can't figure it out how to do it.

I know that in time i will find out how to do it Smile.

Thanks for all your support!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.