Advertisement:

Author Topic: Watchlist pluggin done !  (Read 32219 times)

AdMeGreek

  • Full Member
  • ***
  • Posts: 101
Re: Watchlist pluggin done !
« Reply #75 on: November 23, 2014, 05:41:31 am »
How I configure the page when someone click at "Watchlist" at user-dashboard
At this time the page shows like this http://prntscr.com/5960rn
but i want same like my theme dashboard. http://prntscr.com/5969tp

I use Tuffclassified theme... can anyone knows??
Thanks
« Last Edit: November 23, 2014, 06:17:34 am by AdMeGreek »

AdMeGreek

  • Full Member
  • ***
  • Posts: 101
Re: Watchlist pluggin done !
« Reply #76 on: November 23, 2014, 06:42:11 am »
jepp, same problem, add to watchlist comes again, and pages not working...


i would like to have the watchlist in dashboard (symnel) for user, now it is the on custom page,
does someone know how i can put it to user-custom?

thx

attached german language 1.0.7 changed watchlist -> Favoriten


to fix the paginaton for the moment i change itemsperpage to "0" now you see all


OK, just for the moment i fixed the the add to watchlist problem for me

change function watchlist (u need to style your button)
the ajax button when adding to watchlist is still working

Code: [Select]
function watchlist() {
      //  echo '<a href="javascript://" class="watchlist seller btn btn-default btn-xs" id="' . osc_item_id() . '">';
//        echo '' . __('Add to watchlist', 'watchlist') . '';
//        echo '</a>';

  if ( osc_is_web_user_logged_in() ) {
            //check if the item is not already in the watchlist
            $conn   = getConnection();
            $detail = $conn->osc_dbFetchResult("SELECT * FROM %st_item_watchlist WHERE fk_i_item_id = %d and fk_i_user_id = %d", DB_TABLE_PREFIX,  osc_item_id() , osc_logged_user_id());

  }
    //If nothing returned then we can process
            if (!isset($detail['fk_i_item_id'])) {
               echo '<a href="javascript://" class="watchlist seller btn btn-default btn-xs" id="' . osc_item_id() . '">';
echo '' . __('Add to watchlist', 'watchlist') . '';
echo '</a>';

            } else {
  echo '<a href="' . osc_base_url(true) . '?page=custom&file=watchlist/watchlist.php" class="watchlist seller btn btn-default btn-xs">' . __('View your watchlist', 'watchlist') . '</a>';
}

    }

I try this code but when I click "Add to Watchlist" I receive an error :/

nicat323

  • Newbie
  • *
  • Posts: 4
Re: Watchlist pluggin done !!!
« Reply #77 on: April 02, 2015, 01:06:06 am »
Great plugin! thanks for taking the time to produce this, I have a small problem however.

It all works fine, if I add the item to the watchlist the button changes to "View your watchlist" but, if I refresh the page it will say "Add to watchlist" even though it's already added.

I have this in the ajax_watchlist.php
Code: [Select]
<?php

    
if (Params::getParam('id') != '') {
        
$id    Params::getParam('id');
        
$count 0;

        if ( 
osc_is_web_user_logged_in() ) {
            
//check if the item is not already in the watchlist
            
$conn   getConnection();
            
$detail $conn->osc_dbFetchResult("SELECT * FROM %st_item_watchlist WHERE fk_i_item_id = %d and fk_i_user_id = %d"DB_TABLE_PREFIX$idosc_logged_user_id());

            
//If nothing returned then we can process
            
if (!isset($detail['fk_i_item_id'])) {
                
$conn getConnection();
                
$conn->osc_dbExec("INSERT INTO %st_item_watchlist (fk_i_item_id, fk_i_user_id) VALUES (%d, '%d')"DB_TABLE_PREFIX$idosc_logged_user_id());
                
?>

                <span align="left">
                    <a href="<?php echo osc_base_url(true); ?>?page=custom&file=watchlist/watchlist.php">
                        <?php _e('View your watchlist''watchlist'?>
                    </a>
                </span>
                <?
            } else {
                //Already in watchlist !
                echo '<span align="left"><a href="' . osc_base_url(true) . '?page=custom&file=watchlist/watchlist.php">' . __('View your watchlist', 'watchlist') . '</a></span>';
            }
        } else {
            //error user is not login in
            echo '<a href="' . osc_user_login_url() . '">' . __('Please login', 'watchlist') . '</a>';
        }
    }

?>

I tried with both permalinks on and off but same result.

Have this in item.php
Code: [Select]
                    <p class="contact_button">
                        <?php if( !osc_item_is_expired () ) { ?>
                        <?php if( !( ( osc_logged_user_id() == osc_item_user_id() ) && osc_logged_user_id() != ) ) { ?>
                            <?php     if(osc_reg_user_can_contact() && osc_is_web_user_logged_in() || !osc_reg_user_can_contact() ) { ?>
                                <strong style="float:right; margin-right:140px; margin-top:-40px; padding-bottom:8px;"><a href="#contact"><?php _e('Contact seller''modern') ; ?></a></strong><br />
<strong style="float:right; margin-top:-55px; padding-bottom:8px;"> <a href="#watchlist"> <?php watchlist(); ?></strong>
                            <?php     ?>
                        <?php     ?>
                        <?php ?>
                    </p>

Please help.

help help problem

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Watchlist pluggin done !
« Reply #78 on: April 02, 2015, 01:32:39 pm »
Hi @nicat323,

To fix that you need to modify watchlist() function on oc-content/plugins/watchlist/index.php, from the original:

Code: [Select]
    function watchlist() {
        echo '<a href="javascript://" class="watchlist" id="' . osc_item_id() . '">';
        echo '<span>' . __('Add to watchlist', 'watchlist') . '</span>';
        echo '</a>';
    }

to:

Code: [Select]
    function watchlist() {

        $conn = getConnection();
        $watched = $conn->osc_dbFetchResult("SELECT *
FROM  %st_item_watchlist
WHERE fk_i_item_id = '%d'
AND  fk_i_user_id = '%d'", DB_TABLE_PREFIX, osc_item_id(), osc_logged_user_id());
       
        if ($watched) {
            echo '<span align="left"><a href="' . osc_base_url(true) . '?page=custom&file=watchlist/watchlist.php">' . __('View your watchlist', 'watchlist') . '</a></span>';
        } else {
        echo '<a href="javascript://" class="watchlist" id="' . osc_item_id() . '">';
        echo '<span>' .  __('Add to watchlist', 'watchlist') . '</span>';
        echo '</a>';
        }
    }

Regards

sonjoy336

  • Newbie
  • *
  • Posts: 1
Re: Watchlist pluggin done !
« Reply #79 on: April 10, 2015, 05:37:09 am »
When my members logged out from my website then, If they inside the watchlist URL like: http://someone_page/index.php?page=custom&file=watchlist/watchlist.php in browser address bar. After that, they still show the watchlist page with user menu with a massage (You don't have any items yet). But, why my member see the page? Why they does not go on the login page automatically when they are not logged in?
« Last Edit: April 10, 2015, 02:24:36 pm by sonjoy336 »

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Watchlist pluggin done !
« Reply #80 on: June 19, 2015, 11:43:01 am »
Just for sharing, I created a double function similar to what teseo and others already showed earlier in index.php.
The function should be put in the index.php file.

Code: [Select]
//Retreive either nr. of items in watchlist of user or check for specific item in user watchlist
function in_watchlist($userid, $itemid = '') {
                if(!isset($userid) || $userid == '') {return 0;}
$conn = getConnection();
if($itemid != '') {
$result = $conn->osc_dbFetchValue("SELECT Count(*) FROM %st_item_watchlist WHERE fk_i_item_id = '%d' AND fk_i_user_id = '%d'", DB_TABLE_PREFIX, $itemid, $userid);
} else {
$result = $conn->osc_dbFetchValue("SELECT Count(*) FROM %st_item_watchlist WHERE fk_i_user_id = '%d'", DB_TABLE_PREFIX, $userid);
}
return $result;
}

You can use the function in your theme either by calling it with item_id or without item_id but always with user_id as it will return a value of 0 or 1 when item_id is given. Without item_id  it will return the actual nr. of items being watched with the given user_id. I use this for similar reason as earlier code sample to determine if an item for a logged in user is already in the watchlist. The total count of items in a user's watchlist can be used in a similar way the wishlist plugin is showing but this plugin is only for logged-in users.

PS. If you use it in your theme(s) make sure to check if the function exists ie. if the watchlist plugin is installed.


Regards,
Eric

richieboymx

  • Full Member
  • ***
  • Posts: 110
Re: Watchlist pluggin done !
« Reply #81 on: June 20, 2015, 07:02:20 pm »
Hi @nicat323,

To fix that you need to modify watchlist() function on oc-content/plugins/watchlist/index.php, from the original:

Code: [Select]
    function watchlist() {
        echo '<a href="javascript://" class="watchlist" id="' . osc_item_id() . '">';
        echo '<span>' . __('Add to watchlist', 'watchlist') . '</span>';
        echo '</a>';
    }

to:

Code: [Select]
    function watchlist() {

        $conn = getConnection();
        $watched = $conn->osc_dbFetchResult("SELECT *
FROM  %st_item_watchlist
WHERE fk_i_item_id = '%d'
AND  fk_i_user_id = '%d'", DB_TABLE_PREFIX, osc_item_id(), osc_logged_user_id());
       
        if ($watched) {
            echo '<span align="left"><a href="' . osc_base_url(true) . '?page=custom&file=watchlist/watchlist.php">' . __('View your watchlist', 'watchlist') . '</a></span>';
        } else {
        echo '<a href="javascript://" class="watchlist" id="' . osc_item_id() . '">';
        echo '<span>' .  __('Add to watchlist', 'watchlist') . '</span>';
        echo '</a>';
        }
    }

Regards

@teseo

What would the fix be if my watchlist/index.php looks like this:
Code: [Select]
function watchlist() {
echo '<span class="fa-stack fa-lg">';
echo '<i class="fa fa-circle fa-stack-2x"></i><a href="javascript://" class="watchlist" id="' . osc_item_id() . '" title="' . __('Add to watchlist', 'watchlist') . '" rel="nofollow"><i class="fa fa-heart fa-stack-1x fa-inverse"></i></a>';
echo '</span>';
}

Thank you!

monah

  • Full Member
  • ***
  • Posts: 223
Re: Watchlist pluggin done !
« Reply #82 on: September 24, 2015, 10:43:39 am »
Hello ) I have a few questions for the plugin .
1. Is it possible to display in the ad how many users is the current ads in favorites ?
2. I made a reference to the header in the favorites and I want it displays the number of selected announcements ? How to do it?
sorry for my english)

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Watchlist pluggin done !
« Reply #83 on: September 24, 2015, 01:55:54 pm »
1. not yet but that is something I want to have as well so I will look into it. Should not be hard to create.
2. I do not quite understand, that nr. of selected announcements, can you explain a bit more?

Hello ) I have a few questions for the plugin .
1. Is it possible to display in the ad how many users is the current ads in favorites ?
2. I made a reference to the header in the favorites and I want it displays the number of selected announcements ? How to do it?
sorry for my english)

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Watchlist pluggin done !
« Reply #84 on: September 24, 2015, 03:16:22 pm »
Hi,

here is a function I created to get the nr. of followers with a specific item.
I haven't tested it yet but I think it should work okay.

Place the following function inside the file index.php of your watchlist plugin:
Code: [Select]
//Retreive nr. of users following specific item
function followers_count($itemid) {
$count = 0;
$conn = getConnection();
if($itemid != '') {
$count =  $conn->osc_dbFetchValue("SELECT Count(fk_i_item_id) FROM %st_item_watchlist WHERE fk_i_item_id = '%d'", DB_TABLE_PREFIX, $itemid);
}
return $count;
}

Regards,
Eric

monah

  • Full Member
  • ***
  • Posts: 223
Re: Watchlist pluggin done !
« Reply #85 on: September 24, 2015, 04:19:41 pm »
Hi,

here is a function I created to get the nr. of followers with a specific item.
I haven't tested it yet but I think it should work okay.

Place the following function inside the file index.php of your watchlist plugin:
Code: [Select]
//Retreive nr. of users following specific item
function followers_count($itemid) {
$count = 0;
$conn = getConnection();
if($itemid != '') {
$count =  $conn->osc_dbFetchValue("SELECT Count(fk_i_item_id) FROM %st_item_watchlist WHERE fk_i_item_id = '%d'", DB_TABLE_PREFIX, $itemid);
}
return $count;
}

Regards,
Eric
thank you ) and tell me how to get the result in user-items.php?

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Watchlist pluggin done !
« Reply #86 on: September 24, 2015, 05:38:10 pm »
I use the following code in item.php:
Code: [Select]
<?php if(function_exists('followers_count')) {
$followers followers_count(osc_item_id());
if($followers 0) { ?>

        <p style="margin-left:8px;"><?php echo $followers .' '__('user(s) is/are following this item.','watchlist'); ?></p>
<?php }
?>


To show something similar is user-items.php you need to use above code (or maybe change it a little) in file "loop-single.php" which is used by loop.php which is used by user-items.php


Regards,
Eric

monah

  • Full Member
  • ***
  • Posts: 223
Re: Watchlist pluggin done !
« Reply #87 on: September 24, 2015, 05:55:16 pm »
insert the number of active listings in favorites

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Watchlist pluggin done !
« Reply #88 on: September 24, 2015, 07:53:45 pm »
The function I created does NOT look if ad is still active but when it is in Watchlist the ad most likely is active.

So with regard to your last post Monah, you have a problem or question?

xop32

  • Jr. Member
  • **
  • Posts: 77
  • trend following
Re: Watchlist pluggin done !
« Reply #89 on: June 23, 2016, 03:36:59 am »
on a site I am working on I need to allow users to save watchlist  items into folders they can create

all items added whould just be added to the default folder, without extra folders,  but if a users decides to make extra folders to store watchlist items into, they could select

thinking its quite a bit of work to allow users to create folders into which they can save the items into,

example:

default watchlist
watchlist folder 1
watchlist folder 2
etc

will need to add more elements to the sql to allow this and expand the functions more, anyone ever done anything like this??