*

wfaiiigy

  • **
  • 10 posts
Republish once per day
« on: July 19, 2017, 08:17:20 AM »
Hi..if is possible to set republish once per day..php or javascript

*

MB Themes

Re: Republish once per day
« Reply #1 on: July 19, 2017, 04:26:00 PM »
Plugin does not have such option.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

wfaiiigy

  • **
  • 10 posts
Re: Republish once per day
« Reply #2 on: July 20, 2017, 01:25:49 AM »
I understand, that plugin does not have such option.the question was if with php or javascript add that option manually myself.Am not a master coder but Ι will give a try.which way will be better?cookie or cron job..even with javascript to hide or classify the republish button for 24 hours based on time clicked.Any information you can provide me would be greatly appreciated.

*

MB Themes

Re: Republish once per day
« Reply #3 on: July 20, 2017, 11:19:45 AM »
@wfaiiigy
You can do that in PHP, checking what is time to expiration and show/hide button based on time.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

wfaiiigy

  • **
  • 10 posts
Re: Republish once per day
« Reply #4 on: July 20, 2017, 12:43:58 PM »
Please can you make a simple example or be more specific

*

wfaiiigy

  • **
  • 10 posts
Re: Republish once per day
« Reply #5 on: July 25, 2017, 06:15:26 PM »
I found a way,lazy as always :P

Go to /oc-content/plugins/backoffice_manager/function/republish.php

Find republish_link function on line 108 and replace

Code: [Select]
<?php function republish_link($item_id$link_title NULL$target '_blank') {
  
$link republish_link_raw($item_id);
  
$link_title = ($link_title == '' __('Republish now!''backoffice_manager') : $link_title);

  if(
$link) {
    echo 
'<a style="color:green;font-weight:bold;" href="' $link '" target="' $target '" title="' __('This listing is about expire or has expired. Click to republish this item if it is still valid''backoffice_manager') . '">' $link_title '</a>';
  }
}
?>


to this

Code: [Select]
<?php function republish_link($item_id$link_title NULL$target '_blank') {
  
$link republish_link_raw($item_id);
  
$link_title = ($link_title == '' __('Republish now!''backoffice_manager') : $link_title);

  
//Republish once per day or more
  
$datenow = new DateTime('NOW');
  
$itemdate = new DateTime(substr(osc_item_field('dt_pub_date'),0,10));
  
$diffdate date_diff($itemdate,$datenow);

  
// Days to wait before item can be republished.Change 1 with yours
  
if($link && $diffdate->days >= 1) {
    echo 
'<a style="color:green;font-weight:bold;" href="' $link '" target="' $target '" title="' __('This listing is about expire or has expired. Click to republish this item if it is still valid''backoffice_manager') . '">' $link_title '</a>';
  } else {
     
//echo something else when republish link does not show up
    
}
}
?>



You must check "Allow users to republish listing anytime, not only when listing is about expire."

Remove php tags...

Sharing is caring...
« Last Edit: July 25, 2017, 06:20:48 PM by wfaiiigy »

*

MB Themes

Re: Republish once per day
« Reply #6 on: July 26, 2017, 12:00:39 AM »
@wfaiiigy
Nice one ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

wfaiiigy

  • **
  • 10 posts
Re: Republish once per day fixed
« Reply #7 on: November 03, 2017, 11:33:15 AM »
Script updated because when ads pass midnight can republished...

Now ads can republished at the same time of last republish

Here the fixed code...

Code: [Select]

<?php function republish_link($item_id$link_title NULL$target '_blank') {
  
$link republish_link_raw($item_id);
  
$link_title = ($link_title == '' __('Republish now!''backoffice_manager') : $link_title);

  
//Republish once per day or more
  
$datenow = new DateTime('NOW');
  
$itemdate = new DateTime(osc_item_pub_date()); //Fixed line
  
$diffdate date_diff($itemdate,$datenow);

  
// Days to wait before item can be republished.Change 1 with yours
  
if($link && $diffdate->days >= 1) {
    echo 
'<a style="color:green;font-weight:bold;" href="' $link '" target="' $target '" title="' __('This listing is about expire or has expired. Click to republish this item if it is still valid''backoffice_manager') . '">' $link_title '</a>';
  } else {
     
//echo something else when republish link does not show up
    
}
}
?>



*also remove php tags.

I modified more code about this plugin such as republished counter,remaining time of next republish and different status according republish status.

If anyone wants this features just pm me to share the code!
« Last Edit: November 03, 2017, 11:42:29 AM by wfaiiigy »

*

MB Themes

Re: Republish once per day
« Reply #8 on: November 03, 2017, 12:47:22 PM »
Thanks for sharing ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Republish once per day fixed
« Reply #9 on: June 12, 2018, 06:58:38 AM »
Script updated because when ads pass midnight can republished...

Now ads can republished at the same time of last republish

Here the fixed code...

Code: [Select]

<?php function republish_link($item_id$link_title NULL$target '_blank') {
  
$link republish_link_raw($item_id);
  
$link_title = ($link_title == '' __('Republish now!''backoffice_manager') : $link_title);

  
//Republish once per day or more
  
$datenow = new DateTime('NOW');
  
$itemdate = new DateTime(osc_item_pub_date()); //Fixed line
  
$diffdate date_diff($itemdate,$datenow);

  
// Days to wait before item can be republished.Change 1 with yours
  
if($link && $diffdate->days >= 1) {
    echo 
'<a style="color:green;font-weight:bold;" href="' $link '" target="' $target '" title="' __('This listing is about expire or has expired. Click to republish this item if it is still valid''backoffice_manager') . '">' $link_title '</a>';
  } else {
     
//echo something else when republish link does not show up
    
}
}
?>



*also remove php tags.

I modified more code about this plugin such as republished counter,remaining time of next republish and different status according republish status.

If anyone wants this features just pm me to share the code!



I replaced your code. Put a check mark in the settings "Allow users to republish the listing anytime, not only when the listing is about expire." - but the link in the user panel does not appear after 24 hours, you can also raise at any time; (


------------------------------------

How can I make sure that the user can publish his ad only after 3 hours?
« Last Edit: June 12, 2018, 07:05:17 AM by Александр Лонгардт »