Is there a way to post html code to a block/region?

superflyman

Joined: 2009-11-12
Posts: 24
Posted: Sat, 2010-01-02 00:59

I'm probably just overlooking something but I want to add some html code for widgets in a couple blocks to display in the sidebar and header. Is there a way to create ad-hoc blocks to do this?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2010-01-02 05:33

In the next few days I should be able to whip up a module for this. In the mean time you could use:
http://codex.gallery2.org/Gallery3:Modules:share_bookmark
and edit the view file that shows the html/JS code for a sidebar block.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2010-01-02 07:32

New module attached: in the codex:
http://codex.gallery2.org/Gallery3:Modules:code_block

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
superflyman

Joined: 2009-11-12
Posts: 24
Posted: Sun, 2010-01-03 01:29

Wow, that was super fast! thanks! I added the module but I'm not sure where to configure it... Do I edit the code_block.html.php file itself?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2010-01-03 01:58

Yes. In the future I might add a UI to have a admin page, but since this is a one off deal most people will be comfortable editing a single file.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
superflyman

Joined: 2009-11-12
Posts: 24
Posted: Sun, 2010-01-03 02:13

ok, sounds good, thanks again!

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2010-01-03 03:34

Care to take a shot at doing some documentation for this new module?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
superflyman

Joined: 2009-11-12
Posts: 24
Posted: Mon, 2010-01-04 00:06

Yes, I will do my best to write something up... I'll get back to you soon.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2010-01-04 02:27

Just edit:
http://codex.gallery2.org/Gallery3:Modules:code_block
as you see fit

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Fader

Joined: 2010-01-13
Posts: 15
Posted: Fri, 2010-01-15 11:17

Could you provide example for php/js inserts for dummies? :)

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2010-01-15 14:49

Fader, I don't understand. This is not the place to learn JS and php.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Fader

Joined: 2010-01-13
Posts: 15
Posted: Fri, 2010-01-15 15:11

This misunderstanding.

I don't understand - how to insert code like php/js.
How to edit code_block.html.php file? For example?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2010-01-16 06:00

Fader the module instructs you to edit:
modules/code_block/views/code_block.php

.
For example I did:

<?php defined("SYSPATH") or die("No direct script access.") ?>
<?= module::get_var("code_block", "code"); ?><br />
    <SCRIPT language=JavaScript>

    <!---

      var now=new Date();

      document.write("The Time is "+now);

    // --->

    </SCRIPT>

and it wrote the suff I saved as well as the "The Time is"

then the time.
"
How can we be more specific that that?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Fader

Joined: 2010-01-13
Posts: 15
Posted: Sat, 2010-01-16 20:28

all ok. thanks!

P.S. Sorry for offtopic, but maybe you explain me - how to change the template to add second sidebar on the left side? Or link for this?

I want use your plugin both sides.

Thanks in advance!

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2010-01-16 23:40
Quote:
P.S. Sorry for offtopic,

Please start a new thread.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
superflyman

Joined: 2009-11-12
Posts: 24
Posted: Wed, 2010-01-20 06:31

Actually, aside from the template issue this brings up an interesting question. Is there a way to create multiple code blocks in a sidebar?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2010-01-20 06:44

You could duplicate the code_block module and edit it to be code_block2 and you will have created your own module.
If you get stuck I can whip another up for you.
I guess I should learn how to add 2 blocks with one module.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2010-01-20 07:33
superflyman wrote:
Is there a way to create multiple code blocks in a sidebar?

New module attached:
http://gallery.menalto.com/node/93525#comment-331498
it now has 3 independent blocks to add/reorder.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
way2real

Joined: 2005-09-12
Posts: 39
Posted: Wed, 2010-01-20 16:41

Great solution for custom blocks.

How can I get the code block to show on all pages? For example, code block is not showing on Contact Owner or Dynamic Album pages

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2010-01-21 01:47

Replace the existing file code_block_block.php
with the attached renameing it to code_block_block.php

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
way2real

Joined: 2005-09-12
Posts: 39
Posted: Thu, 2010-01-21 03:03

Perfect. Thanks Floridave.

 
superflyman

Joined: 2009-11-12
Posts: 24
Posted: Thu, 2010-01-21 22:20

The multiple code blocks works great! Thanks!

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2010-01-22 01:10

Glad it is working out. I was thinking of adding a some checkboxes on the admin page to allow the admin to select what type of page to show the block on; album. movie, photo, all.
Think that is a good idea?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Fader

Joined: 2010-01-13
Posts: 15
Posted: Fri, 2010-01-22 10:18

Yes of couse.

I have idea too:

to add code rotate for block (if use js/php script). -> after refresh page this module will load next code from list.

Its really release?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2010-01-22 14:39
Quote:
to add code rotate for block (if use js/php script). -> after refresh page this module will load next code from list.

I don't really understand, can you explain with a example?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Fader

Joined: 2010-01-13
Posts: 15
Posted: Fri, 2010-01-22 15:30

example:

We have 2 js codes that want to add in 1 block, but that they were loaded in turn (not together) after pressing F5 in the browser.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2010-01-22 17:22

I don't think I could do that. Are you thinking something along the lines of a random advertisement?
Got an example of this working outside gallery I can see?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Fader

Joined: 2010-01-13
Posts: 15
Posted: Fri, 2010-01-22 20:37

Right. this used for random advertisement.

I have not exapmle for outside gallery, but there is Ad Rotator plug-in for Wordpress CMS.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2010-01-22 23:14

There is lots of rotation JS scripts out there for adverts. Just plug one into a block and you should be good to go.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
superflyman

Joined: 2009-11-12
Posts: 24
Posted: Sat, 2010-01-23 03:23

I think the checkboxes sound good...

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2010-02-01 00:40

Added some checkboxes to select the type of page the block should be on:
http://gallery.menalto.com/node/93525#comment-331498

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
wats

Joined: 2010-01-27
Posts: 7
Posted: Tue, 2010-02-02 13:33

Please tell me, how i can put in to code blok AdSense coode?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2010-02-02 14:31

paste your code in the /modules/code_block/views/code_block#.html.php file

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
ShakataGaNai

Joined: 2010-02-15
Posts: 2
Posted: Mon, 2010-02-15 18:41

Bug: As of 3.0 Beta 3, every time you click save in admin, it double escapes all special characters. The first time you save, a ' becomes \' , the second becomes \\\' , the third becomes \\\\\\\' ... and so on and so forth.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2010-02-15 21:15

Can you give an example?
Try the lateest version of G3. It was not tested against B3.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2010-03-06 07:44

Updated the module to remove data from the var table on deactivation.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Martinswar
Martinswar's picture

Joined: 2007-10-19
Posts: 18
Posted: Sat, 2010-04-10 02:15

Ok, I updated to latest version of Gallery3 and got the ads to work by downloading, installing, activating and finally editing the (views files) and http://www.nigerianfolks.com/gallery is now at it,s uptimum as i would want it.

Way to go folks.

I promise to donate to this course in the nearest future.

Pretenders are people who lack self confidence...

 
Ser Moro
Ser Moro's picture

Joined: 2007-12-08
Posts: 79
Posted: Thu, 2010-06-10 16:53

The multiple code blocks works OK.
However, gallery pages have several <div id="g-metadata" class="g-block">
and don't validate by validator.w3.org
-=SM=-

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2010-06-10 23:42

Ser Moro,
I fixed the ids in the above zip file:
http://gallery.menalto.com/node/93525#comment-331498
Thanks for the catch.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Ser Moro
Ser Moro's picture

Joined: 2007-12-08
Posts: 79
Posted: Fri, 2010-06-11 13:07

Thank you, Dave. Now - perfect.
-=SM=-

 
reinoutsmit
reinoutsmit's picture

Joined: 2009-09-16
Posts: 3
Posted: Sun, 2010-06-27 20:24
floridave wrote:
Can you give an example?
Try the lateest version of G3. It was not tested against B3.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Tried it on RC1, error is there, solved it for myself by putting everything in the code_block.html.php file
you can see it here, code block is called test 2

 
mystavash

Joined: 2004-09-12
Posts: 69
Posted: Sun, 2010-12-12 03:21

floridave,

To me the instructions were confusing. With the code block, you would normally add the code into the UI. However, for php/jsp, you're saying that that code should be added directly into the files. That's not how I understood it. I thought there was some kind of setting in the files that would allow you to enter php/jsp into the UI. So it was confusing. Just "edit the file" is not enough, it would be great if it said 'edit the file to add the desired php/jsp directly into the code block" or something like that.

Anisa.

floridave wrote:
Fader the module instructs you to edit:
modules/code_block/views/code_block.php

.
For example I did:

<?php defined("SYSPATH") or die("No direct script access.") ?>
<?= module::get_var("code_block", "code"); ?><br />
    <SCRIPT language=JavaScript>

    <!---

      var now=new Date();

      document.write("The Time is "+now);

    // --->

    </SCRIPT>

and it wrote the suff I saved as well as the "The Time is"

then the time.
"
How can we be more specific that that?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2010-12-12 06:28
Quote:
edit the file to add the desired php/jsp directly into the code block

Fixed in the docs:
http://codex.gallery2.org/Gallery3:Modules:code_block#Advanced_usage

Feel free to edit as you see fit. Did you want me to fix the text in the UI as well?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
dwdallam

Joined: 2006-11-19
Posts: 394
Posted: Fri, 2010-12-17 09:26

One of the most useful modules out there. A must have.

 
dwdallam

Joined: 2006-11-19
Posts: 394
Posted: Tue, 2010-12-28 08:53

Is it possible to allow

.sidebar a:hover {color: #FF9933;
}

in the sidebar for code block using "class"?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2010-12-28 15:45

Please explain with a URL.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
dwdallam

Joined: 2006-11-19
Posts: 394
Posted: Tue, 2010-12-28 22:04

OK on the left side you will see your Code Block. Below the heading NAVIGATION you will see three links. I want those to hover if possible:
http://www.dwdallam.com/G3_DWDALLAM/

floridave wrote:
Please explain with a URL.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2010-12-29 02:21

.g-block-content a:hover {color:#0000FF!important;}
Adjust the color as you need.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
dwdallam

Joined: 2006-11-19
Posts: 394
Posted: Wed, 2010-12-29 02:58

Perfect, thanks.

floridave wrote:
.g-block-content a:hover {color:#0000FF!important;}
Adjust the color as you need.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2011-06-17 04:01

Comments are now permitted for this topic.

 
fanky

Joined: 2011-08-19
Posts: 2
Posted: Fri, 2011-08-19 06:42

I'm probably just overlooking something but I want to add some html code for widgets in a couple blocks to display in the sidebar and header. Is there a way to create ad-hoc blocks to do this?