Our site www.viart.com site is operated by latest Viart Shop 5 with default Clear design
Topic Information
Caterpillar (Guest)
Caterpillar (Guest)
How can I insert a block within the greetings by its id
 
This is what I have entered at the Global Settings of Greetings/Introduction :-
 
<table width="650" border="0" align="center">
<tr>
<td width="31%" rowspan="2" valign="top" style="padding-left:30; padding-top:5"><img src="images/riche/headerblockimage.gif" width="176" height="118" hspace="5" vspace="5" align="left"/></td>
<td width="2%"> </td>
<td width="67%" class=""><img src="images/riche/arrow.gif" width="11" height="11" />    <strong>
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="v_shop"; // Database name
$tbl_name="va_custom_blocks"; // Table name
 
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
 
$result = mysql_query("SELECT * FROM $tbl_name WHERE block_id = 2") or die (mysql_error());
while ($row=mysql_fetch_array ($result))
{
echo $row['block_title'];
 
 
?>
</strong></td>
</tr>
<tr>
<td> </td>
<td valign="top"><span class="homeGreetings"><br />
<?php
echo $row['block_desc'];
}
?>
</span></td>
</tr>
</table>
 
The problem is it returns value of the block but goes at the top of the page, but if I enter html characters, it appears within the greeting area.
 
Please help.Searching
 
wendyp (Guest)
wendyp (Guest)
I know this is an old question, but since I found this info quite helpful, I thought I'd share how to get it to work.
 
Make sure the 'Allow PHP code to run in' Greetings/Intro is checked.
 
In the Greetings/Intro box add the following code:
 
<div>
<?php
$result = mysql_query("SELECT * FROM va_custom_blocks WHERE block_id = 12") or die (mysql_error());
while ($row=mysql_fetch_array ($result))
{
$block_body .= $row['block_desc'];
}
?>
</div>
 
When you create the custom block, you can see its ID. Just replace "block_id = 12" with whatever your block ID is.
 
Note the "." before the equal sign in $block_body .=
 
The dot appends to the block_body instead of overwriting it.
 
I was able to use this to put 2 blocks into the greeting area - one div I floated left and the other right. Worked beautifully! Thanks for getting me started.
 
/Wendy
 
dani
dani
Is this still relevant?
 
I wish there were straightforward instructions on inserting PHP into custom blocks. Everyone seems to be doing something different..
 
SajMalik
SajMalik
We should not have to be adding code like this; many of us are not really programmers and everything should be easily driven by admin - the real solution is for Viart to make it simple to do this from CMS.
 
Why do we keep seeing all these attempts at a 'botch' rather than demands upon Viart to make the changes at the next upgrade? And I don't mean because of any problems some people say they have with Viart - this is so straightforward a need that we should ask for it.
 
Otherwise we are all working as though we have an OS set up and not getting the best from such a product as Viart. NO? I don't know
 
TOCDCO
TOCDCO
Chris - I proposed an idea, but go little to no response. In fact, you're really the only one I believe that liked it.
 
See: http://www.viart.com/cms_layout_design.html I don't know
 
SajMalik
SajMalik
It shows how these thing go around, Dan. Broad grin
 
I hope that Viart reads and picks up on this
- Anjula, could you please respond to this?
 
Chris
 
dani
dani
It would be great to get an answer on this.
 
Hopefully this smiley will inspire someone to reply ==> Heart
 
ewoud (Guest)
ewoud (Guest)
when I try this in multisite setup it works fine on site 1, but not in site 2.
has anyone ever encountered this? if so, is there a fix?