• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 42 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: Nieuws koppelen aan Twitter via UDT en Events [update]
PostPosted: Fri May 11, 2012 9:49 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Tue Nov 29, 2011 10:42 am
Posts: 187
Hoe laat ik pretty urls werken als het cms in een submap staat?En welke Gebeurtenissen Beheer is dan voor nieuws update waar ik hem moet toevoegen?

groetjes pascal


Top
 Profile  
 
 Post subject: Re: Nieuws koppelen aan Twitter via UDT en Events [update]
PostPosted: Fri May 11, 2012 10:16 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Tue Nov 29, 2011 10:42 am
Posts: 187
Oke pretty urls werkt nu aleen nogsteeds het zelfde probleem hij tweet hem niet. als ik ee bericht aanmaak in de nieuws module en versuur word het wit en verder nix pas als ik in het menu weer naar de nieuws module ga staat het bericht er wel aleen de tweet niet

gr pascal


Top
 Profile  
 
 Post subject: Re: Nieuws koppelen aan Twitter via UDT en Events [update]
PostPosted: Fri May 11, 2012 10:43 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Mar 23, 2006 9:25 am
Posts: 1430
Location: The Netherlands
Wil me een account en link per pm sturen, dan wil ik wel met je meekijken.

Grtz. Gregor


Top
 Profile  
 
 Post subject: Re: Nieuws koppelen aan Twitter via UDT en Events [update]
PostPosted: Fri May 11, 2012 11:30 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Mar 23, 2006 9:25 am
Posts: 1430
Location: The Netherlands
Solved :)

Wat heb ik gedaan:
- de eerste regel in de UDT eruit gehaald
- de functie voor het sturen van een tweet stond onderaan. Die heb ik boven het 'programadeel' gezet (zie ook eerdere post van mij)
- de boolean 'debug' op false gezet; anders komt er geen tweet uit.

Grtz., Gregor


Top
 Profile  
 
 Post subject: Re: Nieuws koppelen aan Twitter via UDT en Events [update]
PostPosted: Fri May 11, 2012 11:41 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Tue Nov 29, 2011 10:42 am
Posts: 187
bedankt voor je hulp Gregor.

Als ik deze Gebruikergedefinieerde tags op een andere website plaats en toevegt aan de NewsArticleAdded dan moet hij gewoon werken?

En in loggen op twitter natuurlijk

Gr pascal


Top
 Profile  
 
 Post subject: Re: Nieuws koppelen aan Twitter via UDT en Events [update]
PostPosted: Fri May 11, 2012 11:49 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Mar 23, 2006 9:25 am
Posts: 1430
Location: The Netherlands
Ja, en pretty urls aanzet ;)
Oja, in je events heb ik nog staan dat bij het wijzigen van een artikel ook een tweet wordt verstuurd. Zie NewsEditArticle. Deze kun je eventueel weghalen.

Succes, Gregor


Top
 Profile  
 
 Post subject: Re: Nieuws koppelen aan Twitter via UDT en Events [update]
PostPosted: Fri May 11, 2012 2:27 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Tue Nov 29, 2011 10:42 am
Posts: 187
Thnx Gregor,

Nog 1 vraagje als je een bericht als concept aan maakt tweet hij deze dan ook?

gr pascal


Top
 Profile  
 
 Post subject: Re: Nieuws koppelen aan Twitter via UDT en Events [update]
PostPosted: Fri May 11, 2012 2:31 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Mar 23, 2006 9:25 am
Posts: 1430
Location: The Netherlands
Nee, daar wordt in de code op gecontroleerd.

Grtz. Gregor


Top
 Profile  
 
 Post subject: Re: Nieuws koppelen aan Twitter via UDT en Events [update]
PostPosted: Mon Jun 25, 2012 4:11 pm 
Offline
New Member

Joined: Thu Mar 29, 2012 8:21 am
Posts: 2
Hey Gregor,

kan je die code met aanpassingen voor pasmaskas misschien hier delen of iets specifieker aangeven wat je hebt aangepast?

Ik zit met exact hetzelfde probleem, alleen voer jouw aanpassingen denk ik niet correct door ;)


Top
 Profile  
 
 Post subject: Re: Nieuws koppelen aan Twitter via UDT en Events [update]
PostPosted: Fri Jun 29, 2012 2:42 pm 
Offline
New Member

Joined: Thu Mar 29, 2012 8:21 am
Posts: 2
iemand die hiermee kan helpen? Want ik kom er echt niet uit.


Top
 Profile  
 
 Post subject: Re: Nieuws koppelen aan Twitter via UDT en Events [update]
PostPosted: Fri Jun 29, 2012 9:50 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Mar 23, 2006 9:25 am
Posts: 1430
Location: The Netherlands
Patmans wrote:
iemand die hiermee kan helpen? Want ik kom er echt niet uit.


Kan je beschrijven waar je niet uitkomt? Wil je het in CGBlog gebruiken?

Grtz., Gregor


Top
 Profile  
 
 Post subject: Re: Nieuws koppelen aan Twitter via UDT en Events [update]
PostPosted: Tue Sep 04, 2012 1:52 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Tue Nov 29, 2011 10:42 am
Posts: 187
Hier de code die Gregor voor mij heeft aangepast:

Code:
/* if(!is_object(cmsms())) exit; */

/******************************************************************************
* about
******************************************************************************/

/*

This UDT can be used to automatically post a Twitter message when a news article is added.
The functionality is based on the Twitter and News module.

- First you need to install and setup the News and Twitter module.
- After you need to create a UDT with this code, for example you can call it: 'news_twitter_update_status'
- At last you need to connect this UDT to the 'NewsArticleAdded' event.
   This can be done via Extensions -> Event Manager.

! Currently this UDT only works when pretty urls are enabled.
It seems that the bit.ly url shortner ($twitter->shortenUrls($link)) has some problems with unfriendly urls.
Querystring parameters &var=1 are converted to &=1 which will break the link.

==
UPDATE: 16 Dec 2011
==

- This UDT is now compatible with cmsms 1.10
- Works with and without pretty urls
- Added the ability to shortenurl's bit.ly problem seems solved
- Added support for the news_url field, if you use these it's best to turnshortenurl's off

==
UPDATE: 4 Jan 2011
==

- Added the $hashtags configuration option


config:

- specify: $detailpage (page_id) of the news detail view if left blank ('') $detailpage will not be used in the url
- specify: $shortenurl (true|false) will use the bit.ly url shortner or not.
- specify: $hashtags (array) to modify the $params['title'] into a title with #hashtags, if $hashtags = array(); no replacement will take place
             : for example: $hashtags = array('cup', 'foo', 'bar');
             : "We have won the cup I repeat worldcup, well that is not my cupoftea" -> "We have won the #cup I repeat #worldcup that is not my #cupoftea"
*/

/******************************************************************************
* globals / objects
******************************************************************************/

$modops = cmsms()->GetModuleOperations();
$twitter = $modops->get_module_instance('Twitter');
$news = $modops->get_module_instance('News');

/******************************************************************************
* config
******************************************************************************/

/* debug (bool) */
$debug = false;
/*s stond op true

/* custom (string) */
$detailpage = '72';

/* shortenurl (bool) */
$shortenurl = true;

/* $hashtags (array) */
$hashtags = array('cup', 'foo', 'bar');

/******************************************************************************
* variables
******************************************************************************/

/* news article related  (string) */
$news_id = $params['news_id'];
$title = $params['title'];

/* added to link (array) */
$link['articleid']  = $params['news_id'];

/*********************************************************************************
* subroutines
*********************************************************************************/

/**
*  fetch the $news_url by $news_id
*
* @param string $news_id
* @return string $news_url
*
*/

function fetch_news_url($news_id) {
   
   $db = cmsms()->GetDb();

   $query = "SELECT news_url
                  FROM ". cms_db_prefix(). "module_news
                  WHERE news_id = ?";

   $news_url = $db->GetOne($query, array($news_id));

   return $news_url;

}


/******************************************************************************
* program
******************************************************************************/

$aliased_title = munge_string_to_url($title);
$aliased_title = strtolower($aliased_title);
$news_url = fetch_news_url($news_id);

if ($news_url != '') {
   $prettyurl = $news_url;
} else {
   if ($detailpage) {
      $prettyurl = 'news/' . $news_id.'/'.$detailpage.'/'.$aliased_title;
   } else {
      $prettyurl = 'news/' . $news_id.'/'.$aliased_title;   
   }
}

$link = $news->CreateLink($news_id, 'detail', $detailpage, '', $link,'', true, false, '', true, $prettyurl);   

// title to hashed_title

      $hashed_title = $title;
     
      if (count($hashtags)) {
     
         $hashtags_pattern = implode('|', $hashtags);
         $words = explode(' ', $title);
         $seen = array();
         
         foreach ($words as $key => $word) {
         
            if (preg_match("/$hashtags_pattern/i", $word) ) {
         
               $stripped_word = preg_replace('/[^A-Za-z-]/','', $word);
         
               if (strlen($word) == strlen($stripped_word)) {
                  if (! in_array($word, $seen) ) {
                     $seen[] = $word;
                     $hashed_title = preg_replace('~\b' . preg_quote($word, '~') . '\b~', '#$0', $hashed_title);
                  }
               }
         
            }
         
         }
     
      }

// strlen check of hashed_title
// math(140 - 22) = 118 ([max_twitter_length] -  [: space $shortlink])

if (strlen($hashed_title) <= 118) {
   $title = $hashed_title;
}

// shortenurl

if ($shortenurl) {
   $shortlink = $twitter->shortenUrls($link);
   $message = $title. ': '. $shortlink;
} else {
   $message = $title. ': '. $link;   
}

// print debug information or  Tweet

if ($debug) {
   print "<pre>twitter: $message status: $params[status] link: $link title: $title prettyurl: $prettyurl \n</pre>";
   exit;
} else {
   if ($params['status'] == 'published') {
      $twitter->updateStatus($message, false);
   }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 42 posts ]  Go to page Previous  1, 2, 3

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner