[contentbox] Adding a PDF link to a page

If that can be achieved it would be better, but not sure how you can do that though.

Sorry just reading through this stuff now. I find it hard to believe that I am the first person that has tried to link to a pdf in page. I have no problem using your solution Andrew (thanks by the way) but this seems like a pretty big contentbox issue right?

Yeah, it is a fundamental problem that I guess can be fixed soon enough. The reason I chose to give you an AOP solution, because at least if ContentBox takes a version or two to get the fix. At least then you still have a solution in place until it is fixed, by just removing the bind in the Module and deleting the AOP it will remove the fix.

And no, I haven’t raise this as a ticket just yet.

You’re probably the first person to use a PDF in the media manager since Luis rolled out the automatic RenderData Formats in ColdBox 3.7.0 which was just last month. Honestly, I’m not sure a ton of people are using the new media manager either. it’s only a few months old.

If you’re uncomfortable with Andrew’s fix, just point your links directory to the content folder for now.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Here’s the ticket then: [CONTENTBOX-354] Can't link to any file via Media Manager that is listed in ColdBox Format Detection - Welcome

Feel free to add anything else in the comments.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Thanks for everything guys! I will work on implementing Andrew’s fix tonight.

Dumb question but is there a base module I can copy from somewhere? I don’t use cfbuilder so i don’t have the utilities. I think I remember reading somewhere that that only thing I actually need to create a module is a module config right?

Look at the Hello Module included with it.

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Sorry guys but I don’t have a whole lot of knowledge about modules. I create a new folder under the root modules folder called cbMediaService.

ModuleConfig.cfc

component {

this.title = “MediaFix”;
this.author = “Dan Vega”;
this.webURL = “”;
this.description = “A Module to fix the media issues in contentbox”;
this.version = “1”;

function configure(){

binder.mapAspect(“cronusCBHotFix”).to("#moduleMapping#.aop.mediaService");
binder.bindAspect(classes=binder.match().instanceOf(“contentbox-ui.handlers.media”),methods=binder.match().methods(“index”),aspects=“cronusCBHotFix”);

}

}

aop/MediaService.cfc

component implements=“coldbox.system.aop.MethodInterceptor” {

property name=“log” inject=“logbox:logger:{this}”;

public any function init(required boolean logResults=“true”) {
instance = {
logResults = arguments.logResults
};
return this;
}

public any function invokeMethod(required invocation) {
var refLocal = {};

var args = invocation.getArgs();
var event = args.event;
var rc = event.getCollection();
var prc = event.getCollection(private = true);

if(prc.currentRoutedUrl.endsWith("/") && structKeyExists(rc, “format”)) {
prc.currentRoutedUrl = left(prc.currentRoutedUrl, len(prc.currentRoutedUrl) - 1) & “.” & rc.format;
}

refLocal.results = arguments.invocation.proceed();

if( structKeyExists(refLocal,“results”) ){
return refLocal.results;
}
}

}

When I try and visit the pdf I get the following error (shortened)

Application Execution ExceptionError Type: WireBox.aop.Mixer.MixinException : [N/A]

Error Messages: Exception mixing in AOP aspect for (modules.contentbox-ui.handlers.media)
Argument output value mismatch.The invokeMethod function does not specify the same value for the output argument in the modules.cbMediaService.aop.MediaService ColdFusion component and the coldbox.system.aop.MethodInterceptor ColdFusion interface.coldfusion.runtime.InterfaceRuntimeExceptions$OutputValuesDoNotMatchException: Argument output value mismatch. at coldfusion.runtime.InterfaceRuntimeExceptions.throwOutputValuesDoNotMatchException(InterfaceRuntimeExceptions.java:356) at

Did you try adding output=false to the method declaration since that is what it’s set to in MethodInterceptor.cfc?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Script methods by default will not generate any output.

Yes I know, but interfaces can be finicky. I don’t know right off if a script component actually has the output value set to false or not.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

lol… damn you Brad :slight_smile: Nice catch

/**

  • @output false
    */
    public any function invokeMethod(required invocation) {
    var refLocal = {};

var args = invocation.getArgs();
var event = args.event;
var rc = event.getCollection();
var prc = event.getCollection(private = true);

if(prc.currentRoutedUrl.endsWith("/") && structKeyExists(rc, “format”)) {
prc.currentRoutedUrl = left(prc.currentRoutedUrl, len(prc.currentRoutedUrl) - 1) & “.” & rc.format;
}

refLocal.results = arguments.invocation.proceed();

if( structKeyExists(refLocal,“results”) ){
return refLocal.results;
}
}

Interesting…

I do not need the output = false in any way shape or form!

Guys, I committed the fix for the PDF links. It is on the development branch. The fix is simple if you need it immediately. I am attaching a git patch here. The change is on the media handler.

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

patch.diff (1.05 KB)

Dan, you should be pleased to know that Luis has a fix for the PDF download complete on the development branch and it is targeted for the 1.6 release:
https://ortussolutions.atlassian.net/browse/CONTENTBOX-354

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Thank you so much for the patch, worked great.