Jump to content

Php İle Bbcode Yapımı


Recommended Posts

Merhaba arkadaşlar. PHP ile BBCODE yapımının nasıl yapıldığını merak ediyorum. Bir video izledim ve yapılanları uyguladım. Ancak merak ettiğim bir şey var Alıntı etiketi yani quote forumlarda gördüğümü kadarıyla bir blok şeklinde gözüküyor div içinde. Ben quote etiketini yaptım ama çıktı halinde öyle bir görsellik göremedim. Bunun için nerede düzenleme yapmam lazım yardımcı olur musunuz? Kodlarımı paylaşıyorum.

<?php

Function BBcode($yazi){
	// Kullanmak istediğimiz bbcode leri listeleyelim.
	
	$bbcode = array(
				'[b]','[/b]',
				'[i]','[/i]',
				'[u]','[/u]',
				'[code]','[/code]',
				'[quote]','[/quote]',
				'[img]','[/img]'
	);
	
	$html = array(
				'<b>','</b>',
				'<i>','</i>',
				'<u>','</u>',
				'<code>','</code>',
				'<quote>','</quote>',
				'<img src="','">'
	);

	$sonYazi = str_replace($bbcode, $html, $yazi);
	return $sonYazi;
}

echo BBcode("[b]Deneme[/b] - [i]Abdullah[/i]")."<br><br>";
echo BBcode("[code]Denemer[/b] - [u][i]Abdullah[/i][/code]")."<br><br>";
echo BBcode("[quote]Bu bir denemedir[/quote]")."<br><br>";
?>
Link to comment
Share on other sites

div'in css özelliklerini ayarladınız mı? Hem yukarıda quote'yi <quote> diye bir etikete dönüştürüyor. Özel etiketlerinizi oluşturdunuz mu?

Kolay gelsin..

Edited by reyiz
Link to comment
Share on other sites

Div ve css az da olsa biliyorum ama bunu bbcode de nasıl uygulanır bilmiyorum malesef. Özel etiket de oluşturmadım. Yukarıdaki koda binaen bir örnek vermeniz mümkün mü acaba? Bu div nereye yazılacak ayrı bir dosya felan mı oluşturulacak. Tam manasıyla anlayamadım.

Link to comment
Share on other sites

<?php

Function BBcode($yazi){
// Kullanmak istediğimiz bbcode leri listeleyelim.

$bbcode = array(
'','',
'','',
'','',
'
','',
'Quote','',
''
);

$html = array(
'<b>','</b>',
'<i>','</i>',
'<u>','</u>',
'<code>','</code>',
'<div class="quote">','</div>',
'<img src="','">'
);

$sonYazi = str_replace($bbcode, $html, $yazi);
return $sonYazi;
}

echo BBcode("Deneme - Abdullah")."<br><br>";
echo BBcode("
Denemer[/b] - [u][i]Abdullah[/i]")."<br><br>";
echo BBcode("QuoteBu bir denemedir")."<br><br>";
?>

Yukarıdaki şekilde kodu düzenlemelisiniz. Sonra da css dosyası içerisine quote classı ile ilgili öznitelikleri tanımlayacaksınız.

<?php 
<link href="css/stil.css" rel="stylesheet" type="text/css"> 
?>

Örnek quote css kodu (tnctr):

blockquote.ipsBlockquote {
font-size: 12px;
padding: 10px;
border: 2px solid #e5e5e5;
border-left: 2px solid #989898;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
background: #f7f7f7;
margin: 0 0;
overflow-x: auto;
}Kolay gelsin..
Edited by reyiz
Link to comment
Share on other sites

<?php

Function BBcode($yazi){
// Kullanmak istediğimiz bbcode leri listeleyelim.

$bbcode = array(
'','',
'','',
'','',
'
','',
'Quote','',
''
);

$html = array(
'<b>','</b>',
'<i>','</i>',
'<u>','</u>',
'<div class="code">','</div>',
'<div class="quote">','</div>',
'<img src="','">'
);

$sonYazi = str_replace($bbcode, $html, $yazi);
return $sonYazi;
}

echo BBcode("Deneme - Abdullah")."<br><br>";
echo BBcode("
Denemer[/b] - [u][i]Abdullah[/i]")."<br><br>";
echo BBcode("QuoteBu bir denemedir")."<br><br>";
?>
Yukarıdaki şekilde kodu düzenlemelisiniz. Sonra da css dosyası içerisine code classı ile ilgili öznitelikleri tanımlayacaksınız.
<?php 
<link href="css/stil.css" rel="stylesheet" type="text/css"> 
?>
Örnek code css kodu (tnctr):
code {
background-color: #fafafa !important;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
-o-border-radius: 4px;
-ms-border-radius: 4px;
-khtml-border-radius: 4px;
border-radius: 4px;
color: #000;
padding: 5px;
border: 1px solid #c9c9c9;
overflow: auto;
margin-left: 10px;
font-size: 13px;
line-height: 140%;
font-family: monospace !important;
}
Kolay gelsin..
Link to comment
Share on other sites

  • 10 ay sonra...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...