HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


'hooks' for forum posts?

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#91472 (In Topic #18396)
Avatar

Community saint

I have been going through the hooks directory, looking at things available.. I haven't seen anything that is a 'hook' to add something to the user's box by each post.

Am I missing something, or does the base source need to be modified to add such a 'hook' in?

If so, would it just be easier to, in that code, do something like an 'if addon_exists('addon')' and put the code all in there?

(i realize the function might not be addonexists, but there is one to check if addon's are installed, just a bit slow this morning)

Paul
Back to the top
 
Posted
Item has a rating of 5 (Liked by Arbo)  
Rating:
#91473
Avatar

Probably best to override OCF_TOPIC_POST.tpl and add in a mini block by making sources_custom/miniblocks/example.php and including it in via {$BLOCK,block=example,member_id={POSTER_ID}} and accessing the member ID in example.php via $map['member_id'].


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#91474
Avatar

Community saint

Ok, makes sense.   Though I think I already modified the .tpl for different mods I made, I will have to 'undo' those changes for a version for the addon.  No problem.

Related question, since I can't find any miniblocks currently in sources to use as a guide, what class do they start with?

Meaning, bocks start with class Block_example … so do miniblocks start with class Miniblock_example ?   Or is that how they should start?

Paul
Back to the top
 
Posted
Item has a rating of 5 (Liked by Arbo)  
Rating:
#91475
Avatar

Though I think I already modified the .tpl for different mods I made, I will have to 'undo' those changes for a version for the addon.

Not ideal I know. Mostly with our own addons this hasn't fortunately happened, but in a few cases we made an override shared between addons and used {$ADDON_INSTALLED,xxx} to determine what customisations should activate.

Related question, since I can't find any miniblocks currently in sources to use as a guide, what class do they start with?

Meaning, bocks start with class Block_example … so do miniblocks start with class Miniblock_example ?   Or is that how they should start?

Miniblocks are trivial – just raw PHP, no class etc. Just echo output out. $map comes automatically defined. ocPortal does magic to make it all work. You could make a sources_custom/blocks/example.php instead but it's more work, and for an unofficial addon there's little gain.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#91476
Avatar

Community saint

Ok.   Since the miniblock is raw php, can I still use normal OCP functions like query_select and such?

Paul
Back to the top
 
Posted
Rating:
#91477
Avatar

Yes, all the ocPortal API is available in there.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#91478
Avatar

You'll find it a lot easier than the AED modules ;). Those have a tonne of abstractions to minimise their code and support a lot of features ocPortal has. Probably the hardest thing that would be desirable for an ocPortal modder to write. With this a "Hello World" example is simply:

Code

<?php
echo 'Hello World';
which is good as a point of principle.

Minimodules are the same as blocks, except they work as pages rather than blocks. So instead of making an AED module you could have made a minimodule doing it, but I didn't suggest it because you'd lose useful conventions and have to hand-code all the form and routing logic from scratch.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#91480
Avatar

Community saint

Yep, straight forward and easy.  Thanks for the info, have it working at a basic level already.


Paul
Back to the top
 
Posted
Rating:
#91486
Avatar

Community saint

How do you convert tempcode to a string?  Using build_url in my minimodule, but it returns tempcode, which can't be 'echo'd …

Found a string to tempcode, but not vice versa.

Paul
Back to the top
 
Posted
Rating:
#91487
Avatar

$tempcode->evaluate()
or
static_evaluate_tempcode($tempcode)

The latter is useful if you need to evaluate the output of a function, as PHP doesn't let you chain method calls direct off a function's return value.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#91488
Avatar

Community saint

Used the latter.  Thanks.


Paul
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: